I²C Bus Stuck Issue – STM32G0 Slave Holding SCL Low During Hot-Swapping
Hello ST Experts,
We are implementing a hot-swappable (plug-and-play) I²C system with STM32G0 slaves, but we are facing an issue where the I²C bus gets stuck due to SCL being held LOW. We need guidance on how to resolve this.
System Overview:
- Master: ESP32-S3
- Slaves: STM32G0 Controllers (Multiple Slaves)
- I²C Bus Setup:
- Pull-up resistors: 4.7kΩ near the master (also tested with 2.2kΩ)
- Slaves are added dynamically using a hot-swapping (plug-and-play) approach
- Default slave address: 0x01 (each slave is reassigned a unique address by the master)
Issue Faced:
- Initially, we connect Slave 1 (0x01) and later reassign its address to 0x60.
- We then add Slave 2 (0x01) and update its address to 0x61 for independent control.
- Problem: When adding the second or subsequent slaves, the SCL line gets pulled LOW continuously, causing the I²C bus to get stuck.
- This suggests that one of the slaves is clock-stretching indefinitely, preventing further communication.
- A manual reset of the stuck slave restores communication, but adding another slave causes the issue again.
Troubleshooting Done:
:white_heavy_check_mark: Changed pull-up resistors from 4.7kΩ to 2.2kΩ → Issue persists
:white_heavy_check_mark: Verified with a logic analyzer → SCL line is being held low by a slave
:white_heavy_check_mark: Suspected bus capacitance or unintended slave behavior during initialization
Key Concern:
- Hot-swappable I²C systems must ensure that newly inserted devices do not interfere with ongoing communication.
- However, in our case, once a slave pulls the SCL line low, neither the master nor any other device can free it up.
- This could be due to an issue in STM32G0 firmware, where the slave isn’t handling I²C accesses correctly after an address reassignment.
- If the slave is not ready, it should return a NACK or ignore data, but instead, it seems to hold the SCL low indefinitely (clock stretching without release).
Questions:
- What could cause the STM32G0 to hold SCL low permanently? Could it be an issue with firmware initialization or interrupt handling?
- How can we ensure that a slave does not stall the I²C bus, especially in a hot-swapping environment?
- Is there a proper way to handle I²C address reassignment on the STM32G0 to avoid this issue?
- Are there any known fixes or best practices to prevent an STM32G0 slave from indefinitely holding SCL low?
Since this is a hot-swappable system, we are particularly interested in techniques to ensure newly connected I²C slaves do not interfere with the ongoing communication.
Any insights or recommendations would be highly appreciated. Thank you in advance for your support!
