TWAI changes in v5.5

kevinevans
Posts: 24
Joined: Thu Aug 25, 2022 10:34 pm

TWAI changes in v5.5

Postby kevinevans » Tue Aug 26, 2025 6:25 pm

Has anybody tried updating their code to use the new TWAI/CAN driver in v5.5? (The changes mentioned here: https://docs.espressif.com/projects/esp ... rface-twai)

I was using the old driver (`twai_driver_install_v2`) for NMEA2000/CAN with ext ids at 250kbps and this was working fairly well, but I'd like to use interrupts over polling.

With the new driver, I noticed that a handful of devices do not work well when attached to the bus using the default settings. I'm finding frames getting dropped with the default config set to 250kbps. I haven't looked too much at it but I'm wondering if anybody else is experiencing the same problems. Do I need to relax the timing requirements here? Is there a macro to set the values to match the old driver's default configs?

My sample code consisted of:
  • twai_new_node_onchip, .tx/.rx pins set, .quanta_clk_out = -1, .bus_off_indicator = -1, .bit_timing.bitrate=250000
  • twai_node_config_mask_filter set to id/mask=0, is_ext=1
  • twai_node_register_event_callbacks
    • on_rx_done would call twai_node_receive_from_isr to receive 8 bytes and push it onto a queue with xSemGiveFromISR
    • on_error would log via ESP_EARLY_LOGW
  • twai_node_enable on the handle created
  • Then I just had a task printing out the stuff from the queue
I noticed that the error handler would log edata->err_flags.val with errors 0x0, 0x10, 0x8. Not sure what these are about, esp. the 0x0.

My old working code was roughly the default config:

Code: Select all

    twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_17, GPIO_NUM_18, TWAI_MODE_NORMAL);
    twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
    twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
Last edited by kevinevans on Wed Aug 27, 2025 5:50 pm, edited 1 time in total.

User avatar
thefury
Posts: 38
Joined: Thu Sep 05, 2019 5:25 pm

Re: TWAI changes in v5.5

Postby thefury » Tue Aug 26, 2025 11:02 pm

Haven't noticed any problems with it in 5.5 at 500k, but I'm polling (third party J1939 library I'm using doesn't have a way to push messages to it).

Does polling still work for you?

Maybe you're taking too long in the ISR, try upping the queue length. I had to set mine to 500 to handle firmware updates over the bus.

kevinevans
Posts: 24
Joined: Thu Aug 25, 2022 10:34 pm

Re: TWAI changes in v5.5

Postby kevinevans » Wed Aug 27, 2025 3:17 pm

Haven't noticed any problems with it in 5.5 at 500k, but I'm polling (third party J1939 library I'm using doesn't have a way to push messages to it).

Does polling still work for you?

Maybe you're taking too long in the ISR, try upping the queue length. I had to set mine to 500 to handle firmware updates over the bus.
Polling still works using the old driver while on v5.5 thankfully.

Are you using the new driver that uses twai_new_node_onchip (in esp_twai.h/esp_twai_onchip.h) or are using the older twai_driver_install/twai_driver_install_v2 (in driver/twai.h)?

In my frame received callback/ISR, I was copying the frame into a freeRTOS queue with xQueueSendFromISR and returning the pxHigherPriorityTaskWoken parameter, so I'm thinking it should be fairly quick. There doesn't seem to be an rx queue any more on the newer driver (only a tx queue). I presume the ISR is supposed to be handling the rx queuing now.

kevinevans
Posts: 24
Joined: Thu Aug 25, 2022 10:34 pm

Re: TWAI changes in v5.5

Postby kevinevans » Wed Aug 27, 2025 8:47 pm

Here's a full example of what I'm experiencing:

Code: Select all

#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"

#include "esp_err.h"
#include "esp_check.h"
#include "esp_log.h"

#include "esp_twai.h"
#include "esp_twai_onchip.h"

static const char TAG[] = "main";

struct nmea_frame {
    uint32_t identifier;

    uint8_t data[8];

    size_t length;
};

static QueueHandle_t rx_queue = NULL;

static bool IRAM_ATTR twai_listener_on_error_callback(twai_node_handle_t handle, const twai_error_event_data_t *edata, void *user_ctx)
{
    ESP_EARLY_LOGW(TAG, "bus error: 0x%x", edata->err_flags.val);
    return false;
}

// Node state
static bool IRAM_ATTR twai_listener_on_state_change_callback(twai_node_handle_t handle, const twai_state_change_event_data_t *edata, void *user_ctx)
{
    const char *twai_state_name[] = {"error_active", "error_warning", "error_passive", "bus_off"};
    ESP_EARLY_LOGI(TAG, "state changed: %s -> %s", twai_state_name[edata->old_sta], twai_state_name[edata->new_sta]);
    return false;
}

static bool IRAM_ATTR nmea_on_received(
    twai_node_handle_t handle,
    const twai_rx_done_event_data_t *edata,
    void *user_ctx
)
{
    struct nmea_frame n2k_frame  = {0};
    BaseType_t woken = pdFALSE;

    twai_frame_t rx_frame = {
        .buffer = n2k_frame.data,
        .buffer_len = sizeof(n2k_frame.data) / sizeof(uint8_t),
    };

    if (twai_node_receive_from_isr(handle, &rx_frame) == ESP_OK) {
        n2k_frame.identifier = rx_frame.header.id;
        n2k_frame.length = rx_frame.header.dlc;

        xQueueSendFromISR(rx_queue, &n2k_frame, &woken);
    }
    return woken == pdTRUE;
}

static esp_err_t nmea_init(twai_node_handle_t *handle) {
    static twai_onchip_node_config_t node_config = {
        .io_cfg.tx = GPIO_NUM_17,
        .io_cfg.rx = GPIO_NUM_18,
        .bit_timing.bitrate = 250000,
        .tx_queue_depth = 5,
    };

    ESP_RETURN_ON_ERROR(
        twai_new_node_onchip(&node_config, handle),
        TAG,
        "failed to create new node"
    );
    
    static twai_event_callbacks_t callbacks = {
        .on_rx_done = nmea_on_received,
        .on_error = twai_listener_on_error_callback,
        .on_state_change = twai_listener_on_state_change_callback,
    };

    ESP_RETURN_ON_ERROR(
        twai_node_register_event_callbacks(
            *handle,
            &callbacks,
            NULL
        ),
        TAG,
        "failed to register cbs"
    );

    ESP_RETURN_ON_ERROR(
        twai_node_enable(*handle),
        TAG,
        "failed to enable"
    );

    return ESP_OK;
}

static esp_err_t nmea_queues_init() {
    rx_queue = xQueueCreate(100, sizeof(struct nmea_frame));

    if (rx_queue == NULL) {
        return ESP_ERR_NO_MEM;
    }

    return ESP_OK;
}

void app_main() {
    twai_node_handle_t handle = NULL;

    ESP_LOGI(TAG, "init");

    ESP_ERROR_CHECK(nmea_queues_init());
    ESP_ERROR_CHECK(nmea_init(&handle));
    
    ESP_LOGI(TAG, "init done");

    struct nmea_frame received_frame = {0};
    for(;;) {
        BaseType_t ret = xQueueReceive(rx_queue, &received_frame, portMAX_DELAY);

        if (ret == pdTRUE) {
            ESP_LOGI(TAG, "received frame with id %" PRIx32, received_frame.identifier);
        } else {
            vTaskDelay(pdMS_TO_TICKS(1000));
        }
    }
}

If I have two other devices on the bus, the 167052034 IDs are fine, but when I start transmitting from the second device (a NMEA2000-compliant device that works with the old polling driver), I start to see a bunch of bus errors.

Code: Select all

I (3394) main: received frame with id 167052034
I (4394) main: received frame with id 167052034
I (5394) main: received frame with id 167052034
I (6394) main: received frame with id 167052034
I (7394) main: received frame with id 167052034
I (8394) main: received frame with id 167052034
I (9394) main: received frame with id 167052034
I (10394) main: received frame with id 167052034
I (11394) main: received frame with id 167052034
I (12394) main: received frame with id 167052034
I (13394) main: received frame with id 167052034
I (14394) main: received frame with id 167052034
I (15394) main: received frame with id 167052034
W (15454) main: bus error: 0x0
W (15454) main: bus error: 0x0
W (15454) main: bus error: 0x0
W (15454) main: bus error: 0x8
W (15454) main: bus error: 0x8
W (15454) main: bus error: 0x0
W (15454) main: bus error: 0x0
I (15454) main: state changed: error_active -> error_warning
W (15454) main: bus error: 0x0
I (15454) main: state changed: error_warning -> error_passive
I (15474) main: received frame with id 418053952
I (15484) main: state changed: error_passive -> error_active
I (15494) main: received frame with id 418316034
I (16394) main: received frame with id 167052034
I (17394) main: received frame with id 167052034
W (17554) main: bus error: 0x0
W (17554) main: bus error: 0x0
W (17554) main: bus error: 0x0
I (17554) main: state changed: error_active -> error_passive
W (17554) main: bus error: 0x8
W (17554) main: bus error: 0x4
W (17554) main: bus error: 0x4
W (17554) main: bus error: 0x4
W (17554) main: bus error: 0x4
W (17604) main: bus error: 0x0
W (17604) main: bus error: 0x0
W (17604) main: bus error: 0x0
W (17654) main: bus error: 0x0
W (17654) main: bus error: 0x0
W (17654) main: bus error: 0x0
W (17704) main: bus error: 0x0
W (17704) main: bus error: 0x0
W (17704) main: bus error: 0x0
I (17734) main: state changed: error_passive -> error_active
I (17744) main: received frame with id 435164162
I (17744) main: received frame with id 435164162
I (17744) main: received frame with id 435164162
I (17744) main: received frame with id 435164162
I (17754) main: received frame with id 435164162
I (17754) main: received frame with id 435164162
I (17764) main: received frame with id 435164162
I (17764) main: received frame with id 435164162
I (17764) main: received frame with id 435164162
I (17774) main: received frame with id 435164162
I (17774) main: received frame with id 435164162
I (17784) main: received frame with id 435164162
I (17784) main: received frame with id 435164162
I (17794) main: received frame with id 435164162
I (17794) main: received frame with id 435164162
I (17794) main: received frame with id 435164162
I (17804) main: received frame with id 435164162
I (17804) main: received frame with id 435164162
I (17814) main: received frame with id 435164162
I (17814) main: received frame with id 435164162
I (17824) main: received frame with id 417873922
W (18254) main: bus error: 0x0
W (18254) main: bus error: 0x0
W (18254) main: bus error: 0x0
I (18254) main: received frame with id 418005056
I (18304) main: received frame with id 418005056
W (18354) main: bus error: 0x0
W (18354) main: bus error: 0x0
W (18354) main: bus error: 0x0
W (18354) main: bus error: 0x8
I (18354) main: state changed: error_active -> error_passive
W (18354) main: bus error: 0x0
I (18384) main: state changed: error_passive -> error_active
I (18394) main: received frame with id 167052034
W (18404) main: bus error: 0x0
W (18404) main: bus error: 0x0
W (18404) main: bus error: 0x0
I (18404) main: state changed: error_active -> error_passive
W (18404) main: bus error: 0x0
I (18434) main: state changed: error_passive -> error_active
I (18444) main: received frame with id 417873922
I (18494) main: received frame with id 417873922
W (18954) main: bus error: 0x0
W (18954) main: bus error: 0x0
W (18954) main: bus error: 0x0
I (18954) main: state changed: error_active -> error_passive
W (18954) main: bus error: 0x0
W (19004) main: bus error: 0x0
W (19004) main: bus error: 0x0
W (19004) main: bus error: 0x0
W (19054) main: bus error: 0x0
W (19054) main: bus error: 0x0
W (19054) main: bus error: 0x0
W (19104) main: bus error: 0x0
W (19104) main: bus error: 0x0
W (19104) main: bus error: 0x0
I (19134) main: state changed: error_passive -> error_active
I (19144) main: received frame with id 417873922
I (19194) main: received frame with id 417873922
I (19394) main: received frame with id 167052034
I (20394) main: received frame with id 167052034
If I just use the second device, the code crashes because we get stuck in the on_error callback loop and can't reset the WDT:

Code: Select all

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403762f0
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x159c
load:0x403c8700,len:0xd24
load:0x403cb700,len:0x2f48
entry 0x403c891c
I (29) boot: ESP-IDF 5.5.0 2nd stage bootloader
I (29) boot: compile time Aug 27 2025 13:40:29
I (29) boot: Multicore bootloader
I (29) boot: chip revision: v0.1
I (32) boot: efuse block revision: v1.2
I (36) boot.esp32s3: Boot SPI Speed : 80MHz
I (39) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 8MB
I (47) boot: Enabling RNG early entropy source...
I (51) boot: Partition Table:
I (54) boot: ## Label            Usage          Type ST Offset   Length
I (60) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 00100000
I (80) boot: End of partition table
I (83) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0b50ch ( 46348) map
I (99) esp_image: segment 1: paddr=0001b534 vaddr=3fc92b00 size=02b18h ( 11032) load
I (101) esp_image: segment 2: paddr=0001e054 vaddr=40374000 size=01fc4h (  8132) load
I (107) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1a50ch (107788) map
I (132) esp_image: segment 4: paddr=0003a534 vaddr=40375fc4 size=0ca94h ( 51860) load
I (144) esp_image: segment 5: paddr=00046fd0 vaddr=600fe000 size=00020h (    32) load
I (150) boot: Loaded app from partition at offset 0x10000
I (150) boot: Disabling RNG early entropy source...
I (161) cpu_start: Multicore app
I (170) cpu_start: Pro cpu start user code
I (170) cpu_start: cpu freq: 160000000 Hz
I (171) app_init: Application information:
I (171) app_init: Project name:     n2k-test
I (175) app_init: App version:      1
I (178) app_init: Compile time:     Aug 27 2025 13:40:17
I (183) app_init: ELF file SHA256:  114d1dfdd...
I (187) app_init: ESP-IDF:          5.5.0
I (191) efuse_init: Min chip rev:     v0.0
I (195) efuse_init: Max chip rev:     v0.99 
I (199) efuse_init: Chip rev:         v0.1
I (203) heap_init: Initializing. RAM available for dynamic allocation:
I (209) heap_init: At 3FC95EF8 len 00053818 (334 KiB): RAM
I (214) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (219) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (224) heap_init: At 600FE020 len 00001FC8 (7 KiB): RTCRAM
I (231) spi_flash: detected chip: gd
I (233) spi_flash: flash io: dio
W (236) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
I (248) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (255) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (262) main_task: Started on CPU0
I (282) main_task: Calling app_main()
I (282) main: init
I (282) main: init done
W (282) main: bus error: 0x8
W (282) main: bus error: 0x8
W (282) main: bus error: 0x0
W (282) main: bus error: 0x0
W (282) main: bus error: 0x0
W (282) main: bus error: 0x8
W (282) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
I (302) main: state changed: error_active -> error_warning
W (302) main: bus error: 0x0
I (302) main: state changed: error_warning -> error_passive
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x4
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x0
W (302) main: bus error: 0x4
W (302) main: bus error: 0x4
W (302) main: bus error: 0x8
W (302) main: bus error: 0x8
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
PC      : 0x40048841  PS      : 0x00060d34  A0      : 0x80048c6c  A1      : 0x3fc93b00  
A2      : 0x00000080  A3      : 0x00000057  A4      : 0x42002600  A5      : 0x3fc93ca0  
A6      : 0x3fcea114  A7      : 0x3fc93108  A8      : 0x60000000  A9      : 0x00000380  
A10     : 0x00000057  A11     : 0x6000001c  A12     : 0x3fcef130  A13     : 0x4037a9be  
A14     : 0x00000080  A15     : 0x3fc98974  SAR     : 0x00000005  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
Core  0 was running in ISR context:
EPC1    : 0x42018693  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40048841


Backtrace: 0x4004883e:0x3fc93b00 0x40048c69:0x3fc93b20 0x40043d03:0x3fc93b40 0x40043cd5:0x3fc93b60 0x40044183:0x3fc93b80 0x40044281:0x3fc93c00 0x4037526e:0x3fc93c50 0x42002482:0x3fc93c70 0x40377585:0x3fc93ca0 0x420025fd:0x3fc98f00 0x42005faa:0x3fc98f20 0x4037b515:0x3fc98f40 0x4037a5d5:0x3fc98f60


Core  1 register dump:
PC      : 0x40377efe  PS      : 0x00060734  A0      : 0x82005fad  A1      : 0x3fc99660  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3fc976a0  A5      : 0x3fc97680  
A6      : 0x4037585c  A7      : 0x00000001  A8      : 0x82006776  A9      : 0x3fc99620  
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3fc97680  A13     : 0x3fc97660  
A14     : 0x00000001  A15     : 0x3fc99834  SAR     : 0x00000000  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  


Backtrace: 0x40377efb:0x3fc99660 0x42005faa:0x3fc99680 0x4037b515:0x3fc996a0 0x4037a5d5:0x3fc996c0




ELF file SHA256: 114d1dfdd

Rebooting...

kevinevans
Posts: 24
Joined: Thu Aug 25, 2022 10:34 pm

Re: TWAI changes in v5.5

Postby kevinevans » Wed Aug 27, 2025 9:31 pm

Solved my problem. It seemed to be a timing issue.

I couldn't figure working values out for twai_timing_basic_config_t. Using sp_permill=800/1000 (80%) didn't work at all but doing the same thing with the advanced config worked. Not sure if there's a rounding problem or what.

Anyway, here's the working timing config:

Code: Select all

    twai_timing_advanced_config_t timing_config = {
        .brp = 16,  // prescaler w/ 80MHz clk. 80MHz/16 => 5 MHz => 200 ns per quanta
        // (80 MHz / 16)/(250 kHz) = number of quanta aka slices per bit = 20
        // so 20 = 1 + tseg1 + tseg2
        // to sample at 80% => 1 _ 15 _ <sample> _ 4
        .tseg_1 = 15,
        .tseg_2 = 4,
        .sjw = 3, // adjustable, allows the controller to adjust the bit timing (i.e. from clock drift)
        .triple_sampling = false,
    };
or with a prop delay:

Code: Select all

    twai_timing_advanced_config_t timing_config = {
        .brp = 16,  // prescaler w/ 80MHz clk. 80MHz/16 => 5 MHz => 200 ns per quanta
        // (80 MHz / 16)/(250 kHz) = number of quanta aka samples per bit = 20
        // so 20 = 1 + tseg1 + tseg2
        // to sample at 80% => 1 _ 15 _ <sample> _ 4
        .prop_seg = 2, // first part = prop_seg+tseg1
        .tseg_1 = 13,
        .tseg_2 = 4,
        .sjw = 3, // adjustable, allows the controller to adjust the bit timing (i.e. from clock drift)
        .triple_sampling = false,
    };
the original code doesn't seem to use a prop time, so I dunno? https://github.com/espressif/esp-idf/bl ... ated.h#L73

User avatar
thefury
Posts: 38
Joined: Thu Sep 05, 2019 5:25 pm

Re: TWAI changes in v5.5

Postby thefury » Thu Aug 28, 2025 4:46 pm

Are you using the new driver that uses twai_new_node_onchip (in esp_twai.h/esp_twai_onchip.h) or are using the older twai_driver_install/twai_driver_install_v2 (in driver/twai.h)?
Oof. I'm a couple generations out of date, not even using v2. Looks like I have some upgrading to do...

wanckl
Espressif staff
Espressif staff
Posts: 6
Joined: Mon Sep 11, 2023 8:24 am

Re: TWAI changes in v5.5

Postby wanckl » Tue Mar 31, 2026 9:52 am

Hi @kevinevans :

For `error 0x0`, there is a fix thanks to PR https://github.com/espressif/esp-idf/pull/18100

But for other errors (form_error / stuff_error), it indicate that timing issue on this node, maybe your 2nd device's timing not very accurate, at least not accurate with esp node.

The `sp_permill` is default 800 (80%), adjust this value will adjust the timing sample point in same bitrate, it take same effect with manually config by `twai_timing_advanced_config_t`. You can see what calculated timing param by set log level to debug.

Who is online

Users browsing this forum: dmaxben, PetalBot, Semrush [Bot] and 10 guests