Skip to content
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

Fix serial corruption on x7 chips #844

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions avr/cores/tiny/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@
*_ucsrb |= _udrie;
#else
if(!(LINENIR & _BV(LENTXOK))){
//The buffer was previously empty, so enable TX Complete interrupt and load first byte.
LINENIR = _BV(LENTXOK) | _BV(LENRXOK);
// The buffer was previously empty, so load the first byte, then enable
// the TX Complete interrupt
unsigned char c = _tx_buffer->buffer[_tx_buffer->tail];
_tx_buffer->tail = (_tx_buffer->tail + 1) & (SERIAL_BUFFER_SIZE - 1);
LINDAT = c;
LINENIR = _BV(LENTXOK) | _BV(LENRXOK);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion avr/cores/tiny/Serial0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
if(LINSIR & _BV(LTXOK)) {
//PINA |= _BV(PINA5); //debug
if (tx_buffer.head == tx_buffer.tail) {
// Buffer empty, so disable interrupts
// Buffer empty, so disable the Transmit Performed Interrupt
LINENIR = LENRXOK; //unset LENTXOK
} else {
// There is more data in the output buffer. Send the next byte
Expand Down
Loading