Skip to main content
Visitor II
March 28, 2025
Solved

HAL_I2C_Master_Transmit works, HAL_I2C_Master_Transmit_IT does not.

  • March 28, 2025
  • 1 reply
  • 374 views

I’m trying to replace a blocking call to HAL_I2C_Master_Transmit() with the interrupt version HAL_I2C_Master_Transmit_IT(). The blocking HAL_I2C_Master_Transmit() call works perfectly. The HAL_I2C_Master_Transmit_IT() call sends completely different data. Specifically:

My buffer contains: 00 00 00 00 00 00 00 BF 00 3F 00 00 00 00 00 00 00

When I call HAL_I2C_Master_Transmit(&hi2c4, I2C_ADDRESS, buffer, 17, 100), I see this:

1.png

When I call HAL_I2C_Master_Transmit_IT(&hi2c4, I2C_ADDRESS, buffer, 17), I see unrecognized data:

2.png

I’m using a STM32H755.

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

    Probably the buffer you are sending is going out of scope before the transfer completes. Use a global variable.

    1 reply

    TDKAnswer
    Super User
    March 28, 2025

    Probably the buffer you are sending is going out of scope before the transfer completes. Use a global variable.

    SoCalJimAuthor
    Visitor II
    March 29, 2025

    That was it! Thank you!!!