Skip to main content
Visitor II
June 4, 2021
Solved

STM32CubeMx I2C_TwoBoards_ComDMA Issue

  • June 4, 2021
  • 1 reply
  • 723 views

In the example

 while(HAL_I2C_Master_Transmit_DMA(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)
 {
 /* Error_Handler() function is called when Timeout error occurs.
 When Acknowledge failure occurs (Slave don't acknowledge its address)
 Master restarts communication */
 if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)
 {
 Error_Handler();
 }
 }

I want to know why if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF) here rather than  if (HAL_I2C_GetError(&I2cHandle) == HAL_I2C_ERROR_AF) if I want to judge Acknowledge failure

thanks

    This topic has been closed for replies.
    Best answer by Piranha

    The explanation is written right there in a code comment!

    1 reply

    PiranhaAnswer
    Graduate II
    June 5, 2021

    The explanation is written right there in a code comment!