Skip to content

Behaviour of Uart::flush() differs from AVR #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TomKeddie opened this issue Jan 3, 2016 · 0 comments
Closed

Behaviour of Uart::flush() differs from AVR #82

TomKeddie opened this issue Jan 3, 2016 · 0 comments

Comments

@TomKeddie
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants