XIAO ESP32C3 not working for CAN messages

I am using XIAO ESP32C3 and TJA1050 to capture CAN messages from a vehicle as response to the commands I send. Unfortunately, unsuccessful.
TJA1050 is connected to GPIO 4 (CAN Tx) and 5 (CAN Rx).
Disconnected and TJA1050 and did a loop test just to check if ESP32C3 is working. Messages are getting transmitted successfully but Receive is timing out. Below is my code snippet and result. Need support please.
I am using ESP-IDF extension from VSCode IDE.

Code:

#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include “freertos/FreeRTOS.h”
#include “freertos/task.h”
#include “esp_system.h”
#include “esp_log.h”
#include “driver/twai.h” // For CAN/TWAI driver

static const char *TAG = “TWAI_GO_NO_GO_TEST”;

#define CAN_TX_PIN GPIO_NUM_4
#define CAN_RX_PIN GPIO_NUM_5

void app_main(void)
{
ESP_LOGI(TAG, “— TWAI Self-Test —”);
ESP_LOGI(TAG, “Configuring TWAI driver…”);
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(CAN_TX_PIN, CAN_RX_PIN, TWAI_MODE_NO_ACK);

g_config.alerts_enabled = TWAI_ALERT_ALL;

twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS();
twai_filter_config_t f_config = { .acceptance_code = 0, .acceptance_mask = 0, .single_filter = true };

ESP_LOGI(TAG, "Installing and starting TWAI driver...");
if (twai_driver_install(&g_config, &t_config, &f_config) != ESP_OK) {
    ESP_LOGE(TAG, "Failed to install driver");
    return;
}
if (twai_start() != ESP_OK) {
    ESP_LOGE(TAG, "Failed to start driver");
    twai_driver_uninstall(); // Clean up if start fails
    return;
}
ESP_LOGI(TAG, "Driver started successfully.");

uint32_t alerts;
if (twai_read_alerts(&alerts, 0) == ESP_OK && alerts != 0) {
    ESP_LOGE(TAG, "Alerts detected immediately after start: 0x%" PRIX32, alerts);
    goto cleanup;
}

vTaskDelay(pdMS_TO_TICKS(100));

twai_message_t tx_message = {
    .identifier = 0x123,
    .data_length_code = 4,
    .data = {0xAA, 0xBB, 0xCC, 0xDD}
};

ESP_LOGI(TAG, "Attempting to transmit a single message...");
if (twai_transmit(&tx_message, pdMS_TO_TICKS(1000)) == ESP_OK) {
    ESP_LOGI(TAG, "Transmit successful. Message queued.");
} else {
    ESP_LOGE(TAG, "Transmit FAILED.");
    if (twai_read_alerts(&alerts, 0) == ESP_OK) {
        ESP_LOGE(TAG, "Alerts on TX fail: 0x%" PRIX32, alerts);
    }
    goto cleanup;
}

vTaskDelay(pdMS_TO_TICKS(50));

twai_message_t rx_message;
ESP_LOGI(TAG, "Attempting to receive the message...");
esp_err_t rx_status = twai_receive(&rx_message, pdMS_TO_TICKS(1000));

if (rx_status == ESP_OK) {
    ESP_LOGI(TAG, "Receive successful.");
    if (rx_message.identifier == tx_message.identifier && memcmp(rx_message.data, tx_message.data, 4) == 0) {
        ESP_LOGI(TAG, "*************************************");
        ESP_LOGI(TAG, "*           TEST PASSED             *");
        ESP_LOGI(TAG, "*************************************");
    } else {
        ESP_LOGE(TAG, "TEST FAILED: Mismatched data.");
    }
} else {
    ESP_LOGE(TAG, "TEST FAILED: Receive timed out.");
    twai_status_info_t status_info;
    if (twai_get_status_info(&status_info) == ESP_OK) {
        ESP_LOGE(TAG, "Driver status on RX fail: state=%d, msgs_to_tx=%d, msgs_to_rx=%d",
                 (int)status_info.state, (int)status_info.msgs_to_tx, (int)status_info.msgs_to_rx);
    }
}

cleanup:

ESP_LOGI(TAG, "Stopping and uninstalling driver...");
twai_stop();
twai_driver_uninstall();
ESP_LOGI(TAG, "Driver uninstalled. Test finished.");

}

Result:
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x400462e2
— 0x400462e2: ets_efuse_get_wp_pad in ROM
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x15c0
load:0x403cbf10,len:0xc34
load:0x403ce710,len:0x2ff0
entry 0x403cbf1a
I (24) boot: ESP-IDF v5.5 2nd stage bootloader
I (24) boot: compile time Aug 19 2025 13:57:09
I (25) boot: chip revision: v0.4
I (25) boot: efuse block revision: v1.3
I (28) boot.esp32c3: SPI Speed : 80MHz
I (32) boot.esp32c3: SPI Mode : DIO
I (35) boot.esp32c3: SPI Flash Size : 2MB
I (39) boot: Enabling RNG early entropy source…
I (44) boot: Partition Table:
I (46) boot: ## Label Usage Type ST Offset Length
I (53) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (59) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (66) boot: 2 factory factory app 00 00 00010000 00100000
I (72) boot: End of partition table
I (75) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=072e8h ( 29416) map
I (88) esp_image: segment 1: paddr=00017310 vaddr=3fc8bc00 size=011f8h ( 4600) load
I (91) esp_image: segment 2: paddr=00018510 vaddr=40380000 size=07b08h ( 31496) load
I (103) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=143f4h ( 82932) map
I (118) esp_image: segment 4: paddr=0003441c vaddr=40387b08 size=03ff8h ( 16376) load
I (122) esp_image: segment 5: paddr=0003841c vaddr=50000000 size=00020h ( 32) load
I (126) boot: Loaded app from partition at offset 0x10000
I (127) boot: Disabling RNG early entropy source…
I (143) cpu_start: Unicore app
I (152) cpu_start: Pro cpu start user code
I (152) cpu_start: cpu freq: 160000000 Hz
I (152) app_init: Application information:
I (152) app_init: Project name: obd2simpletest
I (156) app_init: App version: 1
I (160) app_init: Compile time: Aug 20 2025 19:18:33
I (165) app_init: ELF file SHA256: 5ee76dc57…
I (169) app_init: ESP-IDF: v5.5
I (173) efuse_init: Min chip rev: v0.3
I (177) efuse_init: Max chip rev: v1.99
I (181) efuse_init: Chip rev: v0.4
I (185) heap_init: Initializing. RAM available for dynamic allocation:
I (191) heap_init: At 3FC8DC50 len 000323B0 (200 KiB): RAM
I (196) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (202) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (208) heap_init: At 50000020 len 00001FC8 (7 KiB): RTCRAM
I (214) spi_flash: detected chip: generic
I (217) spi_flash: flash io: dio
W (220) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (232) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (238) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (245) main_task: Started on CPU0
I (245) main_task: Calling app_main()
I (245) TWAI_GO_NO_GO_TEST: — TWAI Single-Shot Self-Test —
I (255) TWAI_GO_NO_GO_TEST: Configuring TWAI driver…
I (255) TWAI_GO_NO_GO_TEST: Installing and starting TWAI driver…
I (265) TWAI_GO_NO_GO_TEST: Driver started successfully.
I (365) TWAI_GO_NO_GO_TEST: Attempting to transmit a single message…
I (365) TWAI_GO_NO_GO_TEST: Transmit successful. Message queued.
I (365) TWAI_GO_NO_GO_TEST: Yielding CPU to allow driver processing…
I (415) TWAI_GO_NO_GO_TEST: Attempting to receive the message…
E (1415) TWAI_GO_NO_GO_TEST: TEST FAILED: Receive timed out.
E (1415) TWAI_GO_NO_GO_TEST: Driver status on RX fail: state=1, msgs_to_tx=1, msgs_to_rx=0
I (1415) TWAI_GO_NO_GO_TEST: Stopping and uninstalling driver…
I (1415) TWAI_GO_NO_GO_TEST: Driver uninstalled. Test finished.
I (1425) main_task: Returned from app_main()