Closed
Description
On AVR Uart::flush checks TXC0 and waits until transmission is complete.
From hardware/arduino/avr/cores/arduino/HardwareSerial.cpp
while (bit_is_set(*_ucsrb, UDRIE0) || bit_is_clear(*_ucsra, TXC0)) {
On SAMD Uart::flush checks DRE
while(sercom->USART.INTFLAG.bit.DRE != SERCOM_USART_INTFLAG_DRE);
DRE is cleared when the data register is empty but the shift register might not be - giving a false early indication the transmission is complete. SERCOM::flush should check TXC in the same manner as AVR.
I'm working with instrumentation at 1200 baud, when I flush I need to tristate the serial line, with the current implementation the last character is corrupted because the flush returns early.