arduino / arduino/ArduinoCore-sam

Due hangs with Serial.write and interrupts disable/enable

Open
#75 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
91
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Hi,

I tried the following code on Due and found the board hung after sending "startcst". Same code on Uno or Mega worked fine with "startcstopstartcstop...." output.

The Serial.write between the two interrupt APIs seemed to have caused the problem. I know it is probably not good to call serial functions with interrupts all disabled as serial relies on them to work. But it seems that, in avr core, some logic has been added to still work with such situation(please correct me if wrong). I did not see a similar logic in the sam core, hence used the following code to try it out. My expectation(not that I like it) was that Due shall hang on the Serial.write('c') line rather than in the middle of the last Serial.write where all interrupts have been re-enabled.

I saw and read issue arduino/Arduino#2405, but not sure if this is a result of it.

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.write("start\0");
noInterrupts();
Serial.write('c');
interrupts();
Serial.write("stop\0");
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Due sketch using Serial.write(), noInterrupts(), and interrupts(), then trace the SAM core's serial implementation and interrupt handling. Compare its behavior with the AVR core logic referenced in the report and define done as resolving the hang while preserving the expected output sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
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.