Forums

LM75 on LPC2148 using I2C

Started by abdhjops April 23, 2009
hi,

i'm trying to get the lm75 temp sensor to work on the lpc2148 using the i2c bus. i'm using the IAR IDE so the only RTOS i could get to compile is micrium's u-cos2.

i was wondering if anyone could help me with the proper sequence to read the sensor. i'm using yuri's code and trying to call it from u-cos2:

void i2c_lpc_init(int Mode);
int lm75_read16(int cs_val, int reg, int *ret_val);
int lm75_read_cfg(int cs_val,int *ret_val);
int lm75_write16(int cs_val, int reg, int wr_val);
int lm75_write_cfg(int cs_val,int wr_val);
int lm75_init();
int lm75_get_temp(int *ret_val);

thanks,
mark

An Engineer's Guide to the LPC2100 Series

There's some LM75 driver code in the I2C examples at http://jcwren.com/arm

--jc

On Thu, Apr 23, 2009 at 10:33 AM, abdhjops wrote:

> hi,
>
> i'm trying to get the lm75 temp sensor to work on the lpc2148 using the i2c
> bus. i'm using the IAR IDE so the only RTOS i could get to compile is
> micrium's u-cos2.
>
> i was wondering if anyone could help me with the proper sequence to read
> the sensor. i'm using yuri's code and trying to call it from u-cos2:
>
> void i2c_lpc_init(int Mode);
> int lm75_read16(int cs_val, int reg, int *ret_val);
> int lm75_read_cfg(int cs_val,int *ret_val);
> int lm75_write16(int cs_val, int reg, int wr_val);
> int lm75_write_cfg(int cs_val,int wr_val);
> int lm75_init();
> int lm75_get_temp(int *ret_val);
>
> thanks,
> mark
>
>
>


hi jc,

i looked at your driver code and for whatever reason, i couldn't get it to properly compile on AIR.

mark

--- In l..., "J.C. Wren" wrote:
>
> There's some LM75 driver code in the I2C examples at http://jcwren.com/arm
>
> --jc
>
> On Thu, Apr 23, 2009 at 10:33 AM, abdhjops wrote:
>
> >
> >
> > hi,
> >
> > i'm trying to get the lm75 temp sensor to work on the lpc2148 using the i2c
> > bus. i'm using the IAR IDE so the only RTOS i could get to compile is
> > micrium's u-cos2.
> >
> > i was wondering if anyone could help me with the proper sequence to read
> > the sensor. i'm using yuri's code and trying to call it from u-cos2:
> >
> > void i2c_lpc_init(int Mode);
> > int lm75_read16(int cs_val, int reg, int *ret_val);
> > int lm75_read_cfg(int cs_val,int *ret_val);
> > int lm75_write16(int cs_val, int reg, int wr_val);
> > int lm75_write_cfg(int cs_val,int wr_val);
> > int lm75_init();
> > int lm75_get_temp(int *ret_val);
> >
> > thanks,
> > mark
> >
> >
> >
>
>

I have some code at work but one thing you must avoid is reading the device
too often. It's only mentioned in passing on the data sheet, but if you
read too often the A/D conversion never finishes.

----- Original Message -----
From: "abdhjops"
To:
Sent: Thursday, April 23, 2009 7:33 AM
Subject: [lpc2000] LM75 on LPC2148 using I2C
> hi,
>
> i'm trying to get the lm75 temp sensor to work on the lpc2148 using the
> i2c bus. i'm using the IAR IDE so the only RTOS i could get to compile is
> micrium's u-cos2.
>
> i was wondering if anyone could help me with the proper sequence to read
> the sensor. i'm using yuri's code and trying to call it from u-cos2:
>
> void i2c_lpc_init(int Mode);
> int lm75_read16(int cs_val, int reg, int *ret_val);
> int lm75_read_cfg(int cs_val,int *ret_val);
> int lm75_write16(int cs_val, int reg, int wr_val);
> int lm75_write_cfg(int cs_val,int wr_val);
> int lm75_init();
> int lm75_get_temp(int *ret_val);
>
> thanks,
> mark
>
>
hi...this is how i'm initializing i2c and my starting sequence:

#define I2C_FLAG_AA 4
#define I2C_FLAG_STA 32
#define I2C_FLAG_I2EN 64

void my_i2c_init()
{
PINSEL0 |= 0x50; // enable sda/scl pins
I20SCLH = 96; // high duty cycle
I20SCLL = 128; // low duty cycle
I20CONCLR |= 0xFF; // clear all flags
}

void my_i2c_start()
{
I20CONSET |= I2C_FLAG_I2EN; // enable i2c
I20CONSET |= I2C_FLAG_STA; // set start flag
}

i see one pulse at 10ms and that it. the clock is always high and the
data is always high except for the pulse.

i'm not exactly sure how the board works...when i initialize or start,
on the sck pin, am i supposed to see a pulse train? or should i create
my own?

--- In l..., "abdhjops" wrote:
>
> hi,
>
> i'm trying to get the lm75 temp sensor to work on the lpc2148 using
the i2c bus. i'm using the IAR IDE so the only RTOS i could get to
compile is micrium's u-cos2.
>
> i was wondering if anyone could help me with the proper sequence to
read the sensor. i'm using yuri's code and trying to call it from
u-cos2:
>
> void i2c_lpc_init(int Mode);
> int lm75_read16(int cs_val, int reg, int *ret_val);
> int lm75_read_cfg(int cs_val,int *ret_val);
> int lm75_write16(int cs_val, int reg, int wr_val);
> int lm75_write_cfg(int cs_val,int wr_val);
> int lm75_init();
> int lm75_get_temp(int *ret_val);
>
> thanks,
> mark
>



Hi,

What you are seeing is the start condition.You need to send some data to see
clock/data activity.

Regards,

Himanshu Patel

From: l... [mailto:l...] On Behalf Of
abdhjops
Sent: Friday, April 24, 2009 3:20 PM
To: l...
Subject: [lpc2000] Re: LM75 on LPC2148 using I2C

hi...this is how i'm initializing i2c and my starting sequence:

#define I2C_FLAG_AA 4
#define I2C_FLAG_STA 32
#define I2C_FLAG_I2EN 64

void my_i2c_init()
{
PINSEL0 |= 0x50; // enable sda/scl pins
I20SCLH = 96; // high duty cycle
I20SCLL = 128; // low duty cycle
I20CONCLR |= 0xFF; // clear all flags
}

void my_i2c_start()
{
I20CONSET |= I2C_FLAG_I2EN; // enable i2c
I20CONSET |= I2C_FLAG_STA; // set start flag
}

i see one pulse at 10ms and that it. the clock is always high and the
data is always high except for the pulse.

i'm not exactly sure how the board works...when i initialize or start,
on the sck pin, am i supposed to see a pulse train? or should i create
my own?

--- In l... ,
"abdhjops" wrote:
>
> hi,
>
> i'm trying to get the lm75 temp sensor to work on the lpc2148 using
the i2c bus. i'm using the IAR IDE so the only RTOS i could get to
compile is micrium's u-cos2.
>
> i was wondering if anyone could help me with the proper sequence to
read the sensor. i'm using yuri's code and trying to call it from
u-cos2:
>
> void i2c_lpc_init(int Mode);
> int lm75_read16(int cs_val, int reg, int *ret_val);
> int lm75_read_cfg(int cs_val,int *ret_val);
> int lm75_write16(int cs_val, int reg, int wr_val);
> int lm75_write_cfg(int cs_val,int wr_val);
> int lm75_init();
> int lm75_get_temp(int *ret_val);
>
> thanks,
> mark
>