Skip to content

Commit ca37340

Browse files
committed
Move UART pins initialization later
Fixes #37
1 parent daa9b77 commit ca37340

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: cores/arduino/UART.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ void UartClass::begin(unsigned long baud, uint16_t config)
147147

148148
_written = false;
149149

150-
//Set up the rx pin
151-
pinMode(_hwserial_rx_pin, INPUT_PULLUP);
152-
153-
//Set up the tx pin
154-
digitalWrite(_hwserial_tx_pin, HIGH);
155-
pinMode(_hwserial_tx_pin, OUTPUT);
156-
157150
int8_t sigrow_val = SIGROW.OSC16ERR5V;
158151
baud_setting *= (1024 + sigrow_val);
159152
baud_setting /= (1024 - abs(sigrow_val));
@@ -169,6 +162,13 @@ void UartClass::begin(unsigned long baud, uint16_t config)
169162

170163
(*_hwserial_module).CTRLA |= USART_RXCIE_bm;
171164

165+
//Set up the rx pin
166+
pinMode(_hwserial_rx_pin, INPUT_PULLUP);
167+
168+
//Set up the tx pin
169+
digitalWrite(_hwserial_tx_pin, HIGH);
170+
pinMode(_hwserial_tx_pin, OUTPUT);
171+
172172
// Restore SREG content
173173
SREG = oldSREG;
174174
}

0 commit comments

Comments
 (0)