AnsweredAssumed Answered

I2C blocks on STM32F4 HAL_I2C_IsDeviceReady HAL v1.6

Question asked by Fahrni.Christoph on Jan 9, 2017
Latest reply on Jan 20, 2017 by Fahrni.Christoph

My software checks the I2C state of a device by calling if( HAL_I2C_IsDeviceReady(hi2c, addr, 2, 15)!= HAL_OK).

There are several changes in the new Version of HAL V1.6.

The problem is the expired Delay tickstart within the do..while loop: If the loop is the 2nd run, the Function I2C_WaitOnFlagUntilTimeout does not wait until the Start is done. Then the code breaks with HAL_TIMEOUT and the bus lanes SDA and SCL are both low.

A workaround could be to renew the tickstart in the following part of the code:

      /* Generate Start */
      hi2c->Instance->CR1 |= I2C_CR1_START;

 

      /* Wait until SB flag is set */
      tickstart = HAL_GetTick();   // line 3266 added by C. Fahrni
      if(I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_SB, RESET, Timeout, tickstart) != HAL_OK)
      {
        return HAL_TIMEOUT;
      }

 

Maybe there is another workaround. I hope for a bugfix in the next version...

Outcomes