ESP32 - 通过 UART 通信时出现任务错误

ESP32 - Task error while communicating over UART

我目前正在研究通过 UART 在 2 个板(ESP32 和 NUCLEO64)之间进行中断通信。我有以下代码:

#define rxBufferSIZE (256)

void app_main()
{
    UART_init();    
    uart_isr_free(UART_NUM_2); 
    uart_isr_register(UART_NUM_2, uart_intr_handle, NULL, ESP_INTR_FLAG_IRAM, &handle_console);
    uart_enable_rx_intr(UART_NUM_2);

    while (1) 
    { 

    }
}

static void IRAM_ATTR uart_intr_handle(void *arg)
{
    uint16_t rx_fifo_len;
    uint16_t i=0;

    rx_fifo_len = UART2.status.rxfifo_cnt; // read number of bytes in UART buffer

    while(rx_fifo_len)
    {
        UART_SlaveRxBuffer[i] = UART2.fifo.rw_byte; // read all bytes
        i++;
        rx_fifo_len--;
    }


    /* Some additional code */


    uart_clear_intr_status(UART_NUM_2, UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
}

static void UART_init()
{
    /* Configure parameters of an UART driver,
     * communication pins and install the driver */
    uart_config_t uart_config = {
        .baud_rate = 115200,
        .data_bits = UART_DATA_8_BITS,
        .parity    = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
    };
    uart_param_config(UART_NUM_2, &uart_config);
    uart_set_pin(UART_NUM_2, UART_TX, UART_RX, UART_RTS, UART_CTS);
    uart_driver_install(UART_NUM_2, rxBufferSIZE * 2, 0, 0, NULL, 0);
 }

两个板之间的通信每次都正常。问题是我在第一次通信后反复收到以下错误:

我不知道是什么原因造成的,所以非常感谢您的帮助。 提前致谢!

我敢打赌你的 while 循环 运行 的优先级高于 IDLE0,因此 IDLE0 没有机会重置 WDT。

你可以这样做(如果只是为了测试我的想法的话):

while (1)
{
    vTaskDelay(1); // or 2 or 2; units are 10ms unless you changed it.
}