AnsweredAssumed Answered

STM32F1xx HAL I2C Generate Start Failure

Question asked by Williams.Kent.001 on May 1, 2015
Latest reply on May 1, 2015 by Williams.Kent.001
Hello,

I have not been able to successfully use the new STM32F1xx HAL I2C on a STM32F103CB. 

The issue remains the same regardless of the method used (polling, Interrupt, or DMA).

When attempting to write to a slave for the first time, the following always returns HAL_TIMEOUT

static HAL_StatusTypeDef I2C_MasterRequestWrite(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Timeout)
{
 
  /* Generate Start */
  SET_BIT(hi2c->Instance->CR1, I2C_CR1_START);
 
  /* Wait until SB flag is set */
  if(I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_SB, RESET, Timeout) != HAL_OK)
  {
    return HAL_TIMEOUT;
  }

This is because the I2C_FLAG_SB is never set in the SR1 register.

The Start bit in CR1 is clearly being set, so something is not happening after this.

Any help or suggestions would be greatly appreciated.

Thanks

Outcomes