Skip to content

Dual builtin CAN not working on ESP32-C6 #74

@jeroenveer

Description

@jeroenveer

After updating ArduinoESP32 to v3.1.1 the can msg is not transmitted and the board hangs without any error message.


#include <esp32_can.h>

void setup() {
	Serial.begin(115200);

	Serial.println("Initializing ...");

	CAN0.begin(500000);
	CAN0.watchFor();

	//CAN1.begin(500000);
	//CAN1.watchFor();
}

void loop() {

	CAN_FRAME message;
	if (CAN0.read(message)) {
		printFrame(&message);
		message.id = 0x100;
		CAN0.sendFrame(message);
	}

	//CAN_FRAME message2;
	//if (CAN1.read(message2)) {
		//printFrame(&message2);
		//CAN0.sendFrame(message2);
	//}  
}

void printFrame(CAN_FRAME* message)
{
	Serial.print(message->id, HEX);
	if (message->extended) Serial.print(" X ");
	else Serial.print(" S ");
	Serial.print(message->length, DEC);
	for (int i = 0; i < message->length; i++) {
		Serial.print(message->data.byte[i], HEX);
		Serial.print(" ");
	}
	Serial.println();
}

Serial Output

------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Jan 14 2025 11:55:28
  Compile Host OS   : windows
  ESP-IDF Version   : v5.3.2-282-gcfea4f7c98-dirty
  Arduino Version   : 3.1.1
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32C6_DEV
  Arduino Variant   : esp32c6
  Arduino FQBN      : esp32:esp32:esp32c6:UploadSpeed=921600,CDCOnBoot=cdc,CPUFreq=160,FlashFreq=80,FlashMode=qio,FlashSize=8M,PartitionScheme=default,DebugLevel=debug,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default
============ Before Setup End ============
[  4321][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 12 already has type USB_DM (38) with bus 0x4080f178
[  4322][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 13 already has type USB_DP (39) with bus 0x4080f178
VMDPR_[  4333][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 12 already has type USB_DM (38) with bus 0x4080f178
[  4333][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 13 already has type USB_DP (39) with bus 0x4080f178
Initializing ...
[  4334][D][esp32_can_builtin.cpp:268] init(): [CAN] Init called
[  4335][D][esp32_can_builtin.cpp:270] init(): [CAN] Init done
Driver installed - bus 0
Creating queues
Starting can handler task
Starting low level RX task
Driver started - bus 0
[  4337][D][esp32_can_builtin.cpp:272] init(): [CAN] Baudrate set
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   465052 B ( 454.2 KB)
  Free Bytes        :   407628 B ( 398.1 KB)
  Allocated Bytes   :    50648 B (  49.5 KB)
  Minimum Free Bytes:   407628 B ( 398.1 KB)
  Largest Free Block:   376820 B ( 368.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
    12 : USB_DM
    13 : USB_DP
    16 : UART_TX[0]
    17 : UART_RX[0]
============ After Setup End =============
448 S 8 52 8 0 5 A0 0 0 0 

Receiving works fine no issues there but as soon as CAN0.sendFrame() is send the the mcu hangs.
Tested on both ESP32 and ESP32-C6
Transmit works good with arduino v3.0.5 and esp32_can v0.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions