Skip to content

Serial output is garbled if done immediately after calling Serial.begin() #37

Closed
@per1234

Description

@per1234

Arduino Uno WiFi Rev2
Arduino megaAVR Boards 1.8.1
Arduino IDE 1.8.10 Hourly Build 2019/05/21 09:33 / Arduino IDE 1.9.0-beta build 107
Windows 10 64 bit / Ubuntu 19.04

The following code:

void setup() {
  delay(1000);  // to prove the issue is not related to printing immediately after startup
  Serial.begin(9600);
  delayMicroseconds(100);
  Serial.println("hello");  // called after a delay, so it prints fine
  Serial.println("hello");  // just to be sure everything is still printing OK
  Serial.begin(9600);
  Serial.println("hello");  // called without a delay, so it's garbled
}
void loop() {}

results in this output:

hello
hello
⸮⸮⸮⸮5

Without a delay of around 100 us between the call to Serial.begin() and Serial.println(), the output is garbled. As you can see from the output, this is not related to being soon after the program starts. It occurs even with subsequent calls to Serial.begin() (it also would have after the first call without the delay).

I've never experienced this with any other official Arduino board.

I've seen at least two threads on the Arduino Forum so far where this caused confusion.

Metadata

Metadata

Assignees

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