diff --git a/cores/arduino/UART.cpp b/cores/arduino/UART.cpp index fa8098c4..8e0520bc 100644 --- a/cores/arduino/UART.cpp +++ b/cores/arduino/UART.cpp @@ -147,13 +147,6 @@ void UartClass::begin(unsigned long baud, uint16_t config) _written = false; - //Set up the rx pin - pinMode(_hwserial_rx_pin, INPUT_PULLUP); - - //Set up the tx pin - digitalWrite(_hwserial_tx_pin, HIGH); - pinMode(_hwserial_tx_pin, OUTPUT); - int8_t sigrow_val = SIGROW.OSC16ERR5V; baud_setting *= (1024 + sigrow_val); baud_setting /= (1024 - abs(sigrow_val)); @@ -169,6 +162,13 @@ void UartClass::begin(unsigned long baud, uint16_t config) (*_hwserial_module).CTRLA |= USART_RXCIE_bm; + //Set up the rx pin + pinMode(_hwserial_rx_pin, INPUT_PULLUP); + + //Set up the tx pin + digitalWrite(_hwserial_tx_pin, HIGH); + pinMode(_hwserial_tx_pin, OUTPUT); + // Restore SREG content SREG = oldSREG; }