1
\$\begingroup\$

I'm currently working on a driver on an STM32F0 that joins the I2C bus as a slave device. Currently there is no mention in the reference manual on how to handle a Repeated Start Condition, does anyone know how to?

I am currently handling the I2C request in the AddressCallback and am able to send/recieve all the data but when I try to detect a Repeated Start using the NACK flag (From RM: The bit is set by software, cleared by hardware when the NACK is sent, or when a STOP condition or an Address Matched is received, or when PE=0.), the ADDR flag is never set meaning the ISR is never called again.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

I finally got a response from ST. There is no reference to Repeated Start Condition in the F0 documentation nor the F0 HAL examples but there is an example in the L4 firmware packge:

In L4 Firmware repository, look under STM32Cube_FW_L4_V1.8.0\Projects\STM32L496ZG- Nucleo\Examples\I2C\I2C_TwoBoards_RestartComIT

The example shows how to perform a single I2C data buffer TX/RX in Interrupt Mode and with a Repeated Start condition.

\$\endgroup\$
0
\$\begingroup\$

I encountered this issue, as you mentioned there is no support for repeated start condition from I2C HAL driver. If I try to use repeated start code gets stuck in HAL_I2C_Slave_Transmit and HAL_I2C_Slave_Receive functions. If anyone wants to overcome this issue, can try to let the firmware ignore below sections

if (I2C_WaitOnSTOPFlagUntilTimeout(hi2c, Timeout, tickstart) != HAL_OK)
{
  /* Disable Address Acknowledge */
  hi2c->Instance->CR2 |= I2C_CR2_NACK;

  return HAL_ERROR;
}

if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK)
{
  /* Disable Address Acknowledge */
  hi2c->Instance->CR2 |= I2C_CR2_NACK;
  return HAL_ERROR;
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.