官方技术支持能不能帮我看看这个TWAI和UART2冲突问题,一直解决不了
Posted: Thu Nov 27, 2025 5:20 am
ESP32芯片,4.4.2 版本, 为什么执行了UART2初始化后,就无法成功初始化TWAI?各自单独初始化都没问题
(初始化UART2)
===================================
uart_driver_install(UART_NUM_2, RX_BUF_SIZE * 2, 0, 0, NULL, 0);
uart_param_config(UART_NUM_2, &uart_config);
uart_set_pin(UART_NUM_2, TXD_PIN_GNSS, RXD_PIN_GNSS, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_flush(UART_NUM_2);
====================================
(初始化TWAI)
====================================
(ESP_ERROR_CHECK(twai_driver_install(&g_config, &t_config, &f_config));
ESP_ERROR_CHECK(twai_start());
===================================
(报错信息)
===================================
ESP_ERROR_CHECK failed: esp_err_t 0x105 (ESP_ERR_NOT_FOUND) at 0x40091470
0x40091470: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:42
file: "IDF/components/driver/twai.c" line 447
func: twai_driver_install
expression: esp_intr_alloc(ETS_TWAI_INTR_SOURCE, g_config->intr_flags, twai_intr_handler_main, NULL, &p_twai_obj->isr_handle)
abort() was called at PC 0x40091473 on core 0
0x40091473: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:43
Backtrace:0x400819e6:0x3ffced900x4009147d:0x3ffcedb0 0x40096a3e:0x3ffcedd0 0x40091473:0x3ffcee40 0x4010b91a:0x3ffcee60 0x40104c13:0x3ffcee90
0x400819e6: panic_abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/panic.c:402
0x4009147d: esp_system_abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_system.c:128
0x40096a3e: abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/newlib/abort.c:46
0x40091473: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:43
0x4010b91a: twai_driver_install at C:/Espressif/frameworks/esp-idf-v4.4.2/components/driver/twai.c:447 (discriminator 1)
0x40104c13: twai_slave_task at C:/dev/handinsight_iot_springcloud/iot_azure_esp32/components/twai_slave/twai_slave_main.c:995
===============================
(初始化UART2)
===================================
uart_driver_install(UART_NUM_2, RX_BUF_SIZE * 2, 0, 0, NULL, 0);
uart_param_config(UART_NUM_2, &uart_config);
uart_set_pin(UART_NUM_2, TXD_PIN_GNSS, RXD_PIN_GNSS, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_flush(UART_NUM_2);
====================================
(初始化TWAI)
====================================
(ESP_ERROR_CHECK(twai_driver_install(&g_config, &t_config, &f_config));
ESP_ERROR_CHECK(twai_start());
===================================
(报错信息)
===================================
ESP_ERROR_CHECK failed: esp_err_t 0x105 (ESP_ERR_NOT_FOUND) at 0x40091470
0x40091470: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:42
file: "IDF/components/driver/twai.c" line 447
func: twai_driver_install
expression: esp_intr_alloc(ETS_TWAI_INTR_SOURCE, g_config->intr_flags, twai_intr_handler_main, NULL, &p_twai_obj->isr_handle)
abort() was called at PC 0x40091473 on core 0
0x40091473: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:43
Backtrace:0x400819e6:0x3ffced900x4009147d:0x3ffcedb0 0x40096a3e:0x3ffcedd0 0x40091473:0x3ffcee40 0x4010b91a:0x3ffcee60 0x40104c13:0x3ffcee90
0x400819e6: panic_abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/panic.c:402
0x4009147d: esp_system_abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_system.c:128
0x40096a3e: abort at C:/Espressif/frameworks/esp-idf-v4.4.2/components/newlib/abort.c:46
0x40091473: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/esp_err.c:43
0x4010b91a: twai_driver_install at C:/Espressif/frameworks/esp-idf-v4.4.2/components/driver/twai.c:447 (discriminator 1)
0x40104c13: twai_slave_task at C:/dev/handinsight_iot_springcloud/iot_azure_esp32/components/twai_slave/twai_slave_main.c:995
===============================