diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst index 0cf7d81a7e..b4961fd4ed 100644 --- a/docs/esp32/quickref.rst +++ b/docs/esp32/quickref.rst @@ -380,6 +380,9 @@ tx 1 10 17 rx 3 9 16 ===== ===== ===== ===== +On ESP32 with SPIRAM, the default pins for UART1 are ``tx=5`` and ``rx=4`` +to avoid possible conflicts with the SPIRAM pins. + PWM (pulse width modulation) ---------------------------- diff --git a/ports/esp32/machine_uart.c b/ports/esp32/machine_uart.c index a2034b7492..4a0782f744 100644 --- a/ports/esp32/machine_uart.c +++ b/ports/esp32/machine_uart.c @@ -278,8 +278,14 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, self->tx = UART_PIN_NO_CHANGE; // GPIO 1 break; case UART_NUM_1: + #if CONFIG_IDF_TARGET_ESP32 && CONFIG_SPIRAM + // ESP32 usually uses pins 9 and 10 for SPIRAM bus, so avoid those pins as defaults. + self->rx = 4; + self->tx = 5; + #else self->rx = 9; self->tx = 10; + #endif break; #if SOC_UART_HP_NUM > 2 case UART_NUM_2: