AnsweredAssumed Answered

I2C causes STM32F051 to crash/reboot

Question asked by Evert on Nov 29, 2013
Latest reply on Dec 13, 2013 by fm

I've an STM32F051 where i2c modules can be connected (SFP video modules)
These modules should be hot swappable, however it seems that the I2C communication is not dealing properly with these modules because sometimes a crash or reboot occurs when I plugin a i2c module.

I use next code to check if a I2C module is available, only when this check succeeded I retrieve some data from that specified module.
It looks like the crash occurs during this routine, which I borrowed from the LM75 example. Does someone have any idea what might go wrong?
Thanks in advance,

Evert Huijben

ErrorStatus SFP_GetStatus(I2C_TypeDef* I2Cx, uint8_t I2Caddr)
   uint32_t I2C_TimeOut = I2C_TIMEOUT;

  /* Configure slave address, nbytes, reload, end mode and start or stop generation */
  I2C_TransferHandling(I2Cx, I2Caddr, 0, I2C_AutoEnd_Mode, I2C_No_StartStop);

  /* Clear NACKF and STOPF */

  /* Generate start */
  I2C_GenerateSTART(I2Cx, ENABLE);

  /* Wait until timeout elapsed */
  while ((I2C_GetFlagStatus(I2Cx, I2C_ISR_STOPF) == RESET) && (I2C_TimeOut-- != 0));

  /* Check if Temp sensor is ready for use */
  if ((I2C_GetFlagStatus(I2Cx, I2C_ISR_NACKF) != RESET) || (I2C_TimeOut == 0))
    /* Clear NACKF and STOPF */
    I2C_ClearFlag(I2Cx, I2C_ICR_NACKCF | I2C_ICR_STOPCF);

    return ERROR;
    /* Clear STOPF */
    I2C_ClearFlag(I2Cx, I2C_ICR_STOPCF);

    return SUCCESS;