error frame on TWAI initialization
Posted: Mon Nov 20, 2023 1:58 pm
Hello,
I use the twai and can successfully write and receive frames. However, when I reset the esp23 I see error frames showing up. It seems that the esp_tx pin send a negative pulse on initialization which result in an error on the bus. How can I prevent this? You can see what happens on the screenshots I added.
This is the code I use to initialize the twai.
Board: ESP32-S3-DevKitC-1 v1.0
ESP-IDF: platform-espressif32 6.4.0
CAN transceiver: SN65HVD232DR
esp_twai_tx_pin: GPIO_NUM_11
esp_twai_rx_pin: GPIO_NUM_12
I use the twai and can successfully write and receive frames. However, when I reset the esp23 I see error frames showing up. It seems that the esp_tx pin send a negative pulse on initialization which result in an error on the bus. How can I prevent this? You can see what happens on the screenshots I added.
This is the code I use to initialize the twai.
- // Initialize configuration structures using macro initializers
- twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT( CAN_TX,CAN_RX, TWAI_MODE_NORMAL);
- g_config.tx_queue_len = 10;
- twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS();
- twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
- // Install TWAI driver
- // negative pulse occures in next function
- if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK) {
- printf("Driver installed\n");
- } else {
- printf("Failed to install driver\n");
- return;
- }
- // Start TWAI driver
- if (twai_start() == ESP_OK) {
- printf("Driver started\n");
- } else {
- printf("Failed to start driver\n");
- return;
- }
ESP-IDF: platform-espressif32 6.4.0
CAN transceiver: SN65HVD232DR
esp_twai_tx_pin: GPIO_NUM_11
esp_twai_rx_pin: GPIO_NUM_12