I2Cv2 driver

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
Emara
Posts: 6
Joined: Wed Dec 10, 2025 3:05 pm
Has thanked: 4 times
Been thanked: 3 times

I2Cv2 driver

Post by Emara »

Hi everyone,

I’m running into some issues with the I2Cv2 driver on STM32F769 in a high-noise I²C environment and would like some guidance:

1- When the driver receives a NACK, it stops communication on the bus and does not recover until I fully reinitialize the driver (calling i2cStart). Is it expected that recovery from a NACK should be handled at the upper layer, or should the low-level driver attempt automatic recovery?

2-Under very noisy conditions, I’ve observed bursts of interrupts that can trigger sometimes memory corruption (HardFault). I found a related issue in ArduPilot’s repository where they limited the number of isrs:

https://github.com/ArduPilot/ardupilot/pull/12896

However, this looks like an old workaround from 2019, and I haven’t found any equivalent fix in the current ChibiOS versions.

Has anyone here experienced similar behavior with the I2Cv2 driver?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: I2Cv2 driver

Post by Giovanni »

Hi,

The driver can reach an I2C_ERROR state, it is meant to be restarted for recovery. Verify if you get an error state or if it is something else.

Giovanni
Emara
Posts: 6
Joined: Wed Dec 10, 2025 3:05 pm
Has thanked: 4 times
Been thanked: 3 times

Re: I2Cv2 driver

Post by Emara »

Hi thanks for replying,

Yes, for the first point of NACK,the driver reports I2C_ACK_FAILURE, then the driver needs to be restarted by upper layer to recover.
regarding the second point it is hard to reproduce but under high noise environment i get different kinds of errors that's okay, but the problem is the bursts that can cause memory corruption sometimes
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: I2Cv2 driver

Post by Giovanni »

Hi,

It is hard to handle at driver level, you should put control codes or CRCs in your memory for integrity check after transfer. On write you should always read-back and compare.

Giovanni
Post Reply