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