Skip to main content
mb2
Associate II
April 15, 2011
Question

STM32 I2C problem!

  • April 15, 2011
  • 4 replies
  • 949 views
Posted on April 15, 2011 at 13:48

STM32 I2C problem!

    This topic has been closed for replies.

    4 replies

    wfarid
    Associate II
    May 17, 2011
    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

    ColdWeather
    Senior
    May 17, 2011
    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

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

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

    greg_t
    Associate III
    May 17, 2011
    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;