cancel
Showing results for 
Search instead for 
Did you mean: 

I2C - str7 library

sjo
Associate II
Posted on September 22, 2004 at 13:17

I2C - str7 library

2 REPLIES 2
sjo
Associate II
Posted on September 22, 2004 at 10:26

I have converted the str7 lib to gcc and have had no problems except with the I2C routines.

I have tracked the problem to the speed formula. If I use the datasheet formula the routines work all the time, with the lib formula the SB sometimes fails to clear after the address send.

The I2C_SpeedConfig function uses the formula ((FCLK/Clock)/2)-7 to calculate the clock divider

in the datasheet the formula is given as ((fPCLK1 / fSCL) - 7) / 2

which is correct ?

The same also applies to fast mode.

I have also just noticed that the FR2-FR0 are incorrectly set for speeds

I2C_Init changes the value to the restet state of 0x20

but if you call I2C_FCLKConfig the value will not change.

if (FCLK

I2Cx->OAR2 |= 0x00;

should be

if (FCLK

I2Cx->OAR2 &= ~0xE0;

or set OAR2 to 0 in the init routine.

Regards

sjo

[ This message was edited by: sjo on 22-09-2004 15:32 ]

[ This message was edited by: sjo on 22-09-2004 15:37 ]
hichem2
Associate II
Posted on September 22, 2004 at 13:17

Hello, sjo

I agree with you concerning all your remarks;

-In order to calculate the clock divider,I2C_SpeedConfig function msut sue the following formula

((fPCLK1 / fSCL) - 7) / 2

-For the second remark about the OAR2 it will be easier to set OAR2 to 0 in the init routine else all the I2C_FCLKConfig function has to be changed. Regards,

Hich