cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 I2C problem!

mb2
Associate II
Posted on April 15, 2011 at 13:48

STM32 I2C problem!

4 REPLIES 4
ColdWeather
Senior
Posted on May 17, 2011 at 14:31

> SPI_InitTypeDef SPI_InitStructure;

 

 

Why SPI and not I2C?

 

> I2C_Cmd(I2C_EEPROM, ENABLE);

> I2C_Init(I2C_EEPROM, &I2C_InitStructure);

First, another order (Init, then Cmd), but it's enough to call Init only - look at the source code, PE bit is set by Init :). I've tested, it works.

>

I2C_GenerateSTART(I2C_EEPROM, ENABLE);

> while (!I2C_CheckEvent(I2C_EEPROM,

>

I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))

I think, after START has been sent, you should wait for I2C_EVENT_MASTER_MODE_SELECT and there send the Address and wait for

I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED

wfarid
Associate II
Posted on May 17, 2011 at 14:31

Have a look these threads: 

http://tinyurl.com/43nxqsu

http://tinyurl.com/3sthj8a

 

When it didn't work in my case, I initially forced clock pulses on the SCK line as one of the answers say and it worked. Check if both the SDA and SCK lines are high or not.

-Walid

greg_t
Associate II
Posted on May 17, 2011 at 14:31

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

change this line above to :

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

mb2
Associate II
Posted on May 17, 2011 at 14:31

Thanks i will try to see if it will fix my problem!