cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Communication Issues Between STM32F107 and MAX11612 at 400kHz

Dominik_Ciurej
Associate

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?

Dominik_Ciurej_0-1744058251639.png

 

2 REPLIES 2
Peter BENSCH
ST Employee

Welcome @Dominik_Ciurej, to the community!

I2C problems are regularly discussed here in the community and can have a wide variety of causes. However, without more detailed information (pull-ups and their value, relevant sections of your programme, possibly scope images) it will be difficult to help you.

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

As @Peter BENSCH said, we need more detail.

Show your schematic.

Have you used an oscilloscope to look at the I2C lines? That would show up any "analogue" issues not visible on a logic analyser.

 


@Dominik_Ciurej wrote:

 A Saleae logic analyzer shows that some frames contain only 7 bytes,


Do those frames correspond to your spikes?

 


@Dominik_Ciurej wrote:

 I tested the same code on STM32F103 and STM32H563 — the issue does not occur.


Maybe instrument all three; compare & contrast ... ?

 

PS:

Have you tried lowering the speed?

 


@Dominik_Ciurej wrote:

 I tested the same code on STM32F103 and STM32H563


Check for any hardware differences.

Post the schematics

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.