arduino / arduino/ArduinoCore-samd

SERCOM::startTransmissionWIRE() freezes on hardware issue.

Open
#476 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
502
Forks
740
PR merge metrics
No merged PRs in 30d

Description

I have a problem when using I2c with Wire library. When the SDA signal is disturbed by something then sometimes when the process reaches line 530 in SERCOM.cpp it gets stuck in an infinite loop running SERCOM::startTransmissionWIRE() over and over again. If I add a 1500 µS delay before line 530 it seems to get out of the loop. Its like the hardware do not get time to recover without the delay. But a delay would maybe be bad for performance if it's common for this code to be run.
I have this problem on two MKR GSM 1400. Maybe someone can confirm this on different hardware. If I connect SDA to 3V3 I run into this problem.

Here is the lines around SERCOM.cpp:530 with my fix.

if(!isBusOwnerWIRE())
{
// Restart communication after small delay
delayMicroseconds(1500);
startTransmissionWIRE(address >> 1, flag);
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in SERCOM.cpp around line 530 and trace SERCOM::startTransmissionWIRE(), especially the isBusOwnerWIRE() retry path. Reproduce the freeze with the Wire library by disturbing SDA or connecting it to 3V3 on the reported MKR GSM 1400 hardware, then compare behavior with the 1500 µs delay. Done means the transmission no longer loops indefinitely while allowing the bus to recover.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.