ESP32 - 而在UART通信任务的错误

问题描述 投票:0回答:1

我目前正在与2块板(ESP32和NUCLEO64)之间的中断在UART通信。我有以下代码:

#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);
 }

这两个板之间的沟通工作每次。问题是我多次收到以下错误首次通讯后:

enter image description here

我不知道是什么原因造成这种所以任何帮助表示赞赏。先感谢您!

task esp32
1个回答
1
投票

我冒昧地说while循环在比IDLE0更高的优先级运行,因此IDLE0没有得到重置WDT的机会。

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

while (1)
{
    vTaskDelay(1); // or 2 or 2; units are 10ms unless you changed it.
}
© www.soinside.com 2019 - 2024. All rights reserved.