Skip to main content
Associate III
March 28, 2025
Solved

HAL_I2C_Master_Transmit works, HAL_I2C_Master_Transmit_IT does not.

  • March 28, 2025
  • 2 replies
  • 1228 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.

2 replies

TDK
TDKBest answer
March 28, 2025

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

"If you feel a post has answered your question, please click ""Accept as Solution""."
SoCalJimAuthor
Associate III
March 29, 2025

That was it! Thank you!!!