arduino / arduino/ArduinoCore-samd

Serial Flush blocks forever but not only at programm start

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

Description

Hi there

I have a similar issue to #597, but not at the start of my program.

In my code, there is a function which looks like this:

```
void SlaveWaterCOM::send() {

digitalWrite(2, HIGH);

Serial1.write(outbuffer.dataarray, 28);

Serial1.flush();

digitalWrite(2, LOW);
}
```

The function communicates via the Serial1 over a MAX3075, and therefore it needs an enablepin for the driver.

In my program, this is the only point I use the Serial1.write or the Serial1.flush command.

Sadly, the program sometimes hangs at the Serial. Flush() command.

I tracked the issue down to the Sercom->USART.INTFLAG.bit.TXC flag, which seems to never be written.

Has anyone a clue why this could be?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Serial1.flush() implementation and trace how it waits for Sercom->USART.INTFLAG.bit.TXC. Reproduce the intermittent hang with the MAX3075 driver-enable sequence shown in the issue, then determine why TXC is not set and document a verified fix or minimal reproduction.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.