cancel
Showing results for 
Search instead for 
Did you mean: 

some i2c questions

guyvo67
Associate II
Posted on August 22, 2009 at 06:37

some i2c questions

1 REPLY 1
guyvo67
Associate II
Posted on May 17, 2011 at 13:21

Hi all,

First I'm using the ride7 and gcc + ST firmware lib to develop.

Q1. if I put the i2c clock command like below after my GPIO init than it doesn't bring up the clock for it. If I do it before the GPIO init than it works perfect (just after RCC). Most of the other clocks you can put them after the GPIO init why is this needed for i2c clock ?

RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1 | RCC_APB1Periph_I2C2, ENABLE);

(I saw that in the ST code examples this line also comes right behind the RCC and just before the NVIC/GPIO stuff)

Q2. if I ran one of the sample examples which comes with the ride (10bit address example) once this works perfect. If I put the same code in a loop however than it will run for some seconds and stop. But if I put a small delay between the stop condition and the master start condition of the loop this solves the problem. I tried it on several i2c speeds all the same behaviour. Is there some minimum time between each new start generation needed ? And also do I have to do I2C_Cmd(I2C2, ENABLE) I2C_Cmd(I2C1, ENABLE) before each new start generation ?

(See att for routine code)

Sequel on loop:

Meanwhile I ran loop test again without any delays in between and it ran as it should be. Maybe some mistake of mine. I have two cortex's on the same board both having the two i2c peripherals wired up and than you must be careful on assigning the addresses 😉 Now I did it using my DIP switches so I can flash equal images. But never mind my question on using

I2C_Cmd() remains.

Do I have the cmd enable the master too after each start,data tx and stop ? I know this must be done after the slave detected the stop to clear the flag.

(btw files with extension c are refused as attachment)

Cheers

Guy

[ This message was edited by: guyvo67 on 22-08-2009 10:17 ]

[ This message was edited by: guyvo67 on 22-08-2009 10:46 ]

[ This message was edited by: guyvo67 on 22-08-2009 20:47 ]