2025-04-07 1:31 PM - edited 2025-04-07 1:37 PM
Hi,
I'm facing an I2C communication issue between an STM32F107RCT6 microcontroller and the MAX11612EUA ADC. I created a clean project in STM32CubeMX using HAL library v1.1.9.0. I'm using HAL_I2C_Master_Receive_IT() to read data, and in the callback I process the received 8 bytes (4 ADC channels, 2 bytes each). When the I2C bus is set to 400kHz (Fast Mode), I randomly receive incorrect values ("spikes") in the data. A Saleae logic analyzer shows that some frames contain only 7 bytes, and the master unexpectedly sends NACK and STOP. Switching to DMA (HAL_I2C_Master_Receive_DMA()) partly solves the issue — data is correct, but after some time communication hangs. The function returns HAL_BUSY, and HAL_I2C_GetError() reports HAL_I2C_ERROR_TIMEOUT. Recovery is only possible by calling HAL_I2C_DeInit() followed by HAL_I2C_Init(). When the I2C hangs, the entire main program stops for around 286 ms. I tested the same code on STM32F103 and STM32H563 — the issue does not occur. Has anyone experienced a similar problem?