diff --git a/avr/cores/tiny/HardwareSerial.cpp b/avr/cores/tiny/HardwareSerial.cpp index 633102b9..47bb98ba 100644 --- a/avr/cores/tiny/HardwareSerial.cpp +++ b/avr/cores/tiny/HardwareSerial.cpp @@ -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 diff --git a/avr/cores/tiny/Serial0.cpp b/avr/cores/tiny/Serial0.cpp index 4dcdc4bf..636e9b50 100644 --- a/avr/cores/tiny/Serial0.cpp +++ b/avr/cores/tiny/Serial0.cpp @@ -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