Closed
Description
Caused problems while working on RS485 project on Arduino Zero. I flushed the port when switching between RX and TX mode, including at startup (ie before data is sent), which caused the program to block.
Test:
void setup() {
Serial1.begin(9600);
SerialUSB.begin(9600);
// Serial1.write(1); // uncomment to prevent blocking
SerialUSB.flush(); // doesn't block
Serial1.flush(); // blocks everything below if called after Serial1.begin() and before any data sent.
delay(2000);
Serial1.println("Serial1 up and running");
SerialUSB.println("SerialUSB up and running");
delay(3000);
}
int i;
void loop() {
// put your main code here, to run repeatedly:
Serial1.println(i++);
SerialUSB.println(i);
}
The issue appears to be tied to this method:
void SERCOM::flushUART()
{
// Wait for transmission to complete
while(!sercom->USART.INTFLAG.bit.TXC);
}
Metadata
Metadata
Assignees
Labels
No labels