File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,10 @@ void HardwareSerial::_tx_udr_empty_irq(void)
97
97
98
98
// clear the TXC bit -- "can be cleared by writing a one to its bit
99
99
// location". This makes sure flush() won't return until the bytes
100
- // actually got written
101
- sbi (*_ucsra, TXC0);
100
+ // actually got written. Other r/w bits are preserved, and zeroes
101
+ // written to the rest.
102
+
103
+ *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << MPCM0))) | (1 << TXC0);
102
104
103
105
if (_tx_buffer_head == _tx_buffer_tail) {
104
106
// Buffer empty, so disable interrupts
@@ -225,7 +227,7 @@ size_t HardwareSerial::write(uint8_t c)
225
227
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
226
228
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set (*_ucsra, UDRE0)) {
227
229
*_udr = c;
228
- sbi ( *_ucsra, TXC0);
230
+ *_ucsra = (( *_ucsra) & (( 1 << U2X0) | ( 1 << MPCM0))) | ( 1 << TXC0);
229
231
return 1 ;
230
232
}
231
233
tx_buffer_index_t i = (_tx_buffer_head + 1 ) % SERIAL_TX_BUFFER_SIZE;
You can’t perform that action at this time.
0 commit comments