Skip to content

I2C Communication Blocking Microcontroller #1280

@AidenPrevey

Description

@AidenPrevey

I am experiencing an issue where inconsistent wiring on an I2C bus causes my STM32F4 to deadlock. I was able to partially fix the issue by slightly modifying the attach method in i2c_transaction.cpp to also include a check for the error state in the first if (see below for the changes made to my code) along with adding deadlock detection to my RF calls. This has seemed to increase the reliability of the system, but now the system seems to get stuck in the I2C_EV interrupt handler. By probing the bus, I have both seen SDA and SCL staying low while the STM is hung, both without and with the internal pullups being enabled, respectively. Directly connecting those pins to +5v not through an external pullup pulls the device out of the interrupt loop. The wiring issue also sometimes causes the STM to experience a hard fault, but I haven't been able to track where the fault occurs yet, and I believe that it is related to the overall issue.

I am looking for either advice on what changes to make to my code to improve the reliability of my system, or if there are issues within modm's I2C handler that can be improved.

Code Diff.
The project is using the 2021q2 release of modm as an update to 2024q4 caused issues within our code when migrating to fibers. We hope to update eventually, but need more rigorous testing on our end. We are not against adding patches to our own branch. As far as I can tell, the only change to the i2c_master.<cpp|hpp> files is the addition of setting the ISR priority, which has a default of 10 in both places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions