cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F108C8T6 - I2C lock-up

Andrew Neil
Evangelist III
Posted on October 02, 2010 at 09:54

STM32F108C8T6 - I2C lock-up

12 REPLIES 12
Andrew Neil
Evangelist III
Posted on May 17, 2011 at 14:09

No - that makes no difference.

Andrew Neil
Evangelist III
Posted on May 17, 2011 at 14:09

I take that back - I hadn't applied it to all places where I set a STOP condition

When I apply it to all places where I set a STOP condition - it stops hanging!

🙂

John F.
Senior
Posted on May 17, 2011 at 14:09

I use the code below to write to an LTC4151. Your application must be similar.

void LTC4151WriteBuffer(uint8_t* pBuffer, uint8_t NumByteToWrite)

{

  /*!< While the bus is busy */

  while(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))

  {

  }

 

  /*!< Send START condition */

  I2C_GenerateSTART(I2C1, ENABLE);

 

  /*!< Test on EV5 and clear it */

  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT))

  {

  }

 

  /*!< Send address for write */

  I2C_Send7bitAddress(I2C1, LTC4151Address, I2C_Direction_Transmitter);

  /*!< Test on EV6 and clear it */

  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))

  {

  }

  //send the reg select COMMAND byte

  I2C_SendData(I2C1, 0);

  /*!< Test on EV8 and clear it */

  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED))

  {

  }

 

  /*!< While there is data to be written */

  while(NumByteToWrite--) 

  {

    /*!< Send the current byte */

    I2C_SendData(I2C1, *pBuffer);

    /*!< Point to the next byte to be written */

    pBuffer++;

 

    /*!< Test on EV8 and clear it */

    while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED))

    {

    }

  }

  /*!< Send STOP condition */

  I2C_GenerateSTOP(I2C1, ENABLE);

}

The fact you could fix your problem with just 5 NOPs implies a hardware timing restriction which might just be how long it takes the I2C ''engine'' to clock through to the next state.

(Our posts crossed - pleased to hear it's now working.)