Skip to content

Commit 968093c

Browse files
eriknyquistsgbihu
authored andcommitted
Add delay to Serial1.end() allow GPIO lines to settle
Through testing, it was discovered that if Serial1.begin() is called again immediately after Serial1.end(), then any attempt to write data immediately following the begin() call could result in corrupted frames. After calling Serial1.end(), it will be at least 300us before those pins can be used as UART again.
1 parent bf5f42a commit 968093c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cores/arduino/UARTClass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "wiring_constants.h"
2626
#include "wiring_digital.h"
2727

28+
#define SETTLING_TIME 400
29+
2830
extern void UART_Handler(void);
2931
extern void serialEventRun(void) __attribute__((weak));
3032
extern void serialEvent(void) __attribute__((weak));
@@ -115,6 +117,7 @@ void UARTClass::end( void )
115117

116118
SET_PIN_MODE(17, GPIO_MUX_MODE); // Rdx SOC PIN (Arduino header pin 0)
117119
SET_PIN_MODE(16, GPIO_MUX_MODE); // Txd SOC PIN (Arduino header pin 1)
120+
delayMicroseconds(SETTLING_TIME); // wait for lines to settle
118121
}
119122

120123
void UARTClass::setInterruptPriority(uint32_t priority)

0 commit comments

Comments
 (0)