Skip to content

GIGA R1 - SerialX.flush() does not work #737

Open
@KurtE

Description

@KurtE

As I mentioned in the forum post:
SerialX (X=1-4) are unbuffered? surprised

The call to SerialX.flush() does not work as I expected, nor does it comply with the documentation.
https://www.arduino.cc/reference/en/language/functions/communication/serial/flush/

Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.)

To reproduce:

void setup() {
  Serial1.begin(115200);
  pinMode(2, OUTPUT);
}

void loop() {
  digitalWrite(2, HIGH);
  Serial1.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  Serial1.flush();
  digitalWrite(2, LOW);
  delay(1);
  digitalWrite(2, HIGH);
  for (char ch = 'a'; ch <= 'z'; ch++) Serial1.write(ch);
  Serial1.flush();
  digitalWrite(2, LOW);

  delay(1000);
}

Results captured by Logic analyzer:
image

The hardware appears to have a Transfer Complete (TC) status, which looks like it should be able to do this properly.
Alternatively, is to add some random delay after your transfers to make up for this issue, which I personally would prefer to avoid.

Otherwise, you are likely to see variations of this same issue, like: #389

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