frecuency example I2C LPC1114

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

frecuency example I2C LPC1114

1,657 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by thinkchip on Sun Apr 04 16:34:18 MST 2010
Hi, I want to know how to set the frecuency work in the example in lpcxpresso? I want to work at frecuency 100KHz
0 Kudos
Reply
3 Replies

1,520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hfischer on Wed Apr 07 23:22:54 MST 2010
Hi german,

if you use the startup code from the cmsis you could use the defines generated in there. A macro like
#define I2BITFREQ               400000
#define I2SCLH_SCLH        (__SYSTEM_CLOCK/(2*I2BITFREQ)) /* I2C SCL Duty Cycle High Reg */
#define I2SCLL_SCLL        (__SYSTEM_CLOCK/(2*I2BITFREQ))  /* I2C SCL Duty Cycle Low Reg */

would probably the best way, to save wrong oscillator configurations. But think about changing them on runtime

But in the explicit problem with 12MHz and a wished I2C Freq of 100kHz you have a factor of 2 to much in your values.
If you set SCLH= SCLL you get easy values which results in the values for SCLH=SCLL=60 (dec).


Quote:

Could i use directly the example i2ctest.c to read the temperature with this changes?

  I2CWriteLength = 1;
  I2CReadLength =  2;
  I2CMasterBuffer[0] = LM75_ADDR | RD_BIT;
  I2CEngine();

Finally, where's the readed temperature values?



Here the read data will be in the I2CMasterBuffer on the through the ReadLength assigned index. So you can expect the data on index 1 and 2.

Hope i am right with all and it will help you.

Greetings
0 Kudos
Reply

1,520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by german on Wed Apr 07 08:57:10 MST 2010
Dear Member,

I'm trying to read a LM75 temperature I2C sensor. (I2C max frecuency --> 100KHZ) interconnected to a LPC1111/101.

I used the internal oscilator (12 MHz) therefore a 12 MHz I2C_PCLK is set.

I used the register values from UM page130 (Table 145. I2SCLL + I2SCLH values for selected I2C clock values) to set a I2C bit frecuency of 100 KHz.

I2SCLL =120; //it's 120 decimal o hex value?
I2SCLH =120; //it's 120 decimal o hex value?

Are these configuration values correct?

Could i use directly the example i2ctest.c to read the temperature with this changes?

  I2CWriteLength = 1;
  I2CReadLength =  2;
  I2CMasterBuffer[0] = LM75_ADDR | RD_BIT;
  I2CEngine();

Finally, where's the readed temperature values?

Thanks in advance.
0 Kudos
Reply

1,520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hfischer on Tue Apr 06 01:20:22 MST 2010
Hi thinkchip,

look at UM page 129 section 10.7.5.1
This example could be rearrange to the value you need to write in the divider register.

I2Cbitfrequency = I2CPCLK / (I2CSCLH + I2CSCLL)
0 Kudos
Reply