Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual builtin CAN not working on ESP32-C6 #74

Open
jeroenveer opened this issue Jan 14, 2025 · 1 comment
Open

Dual builtin CAN not working on ESP32-C6 #74

jeroenveer opened this issue Jan 14, 2025 · 1 comment

Comments

@jeroenveer
Copy link

jeroenveer commented Jan 14, 2025

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

@jeroenveer
Copy link
Author

The issue was a RS pin of CAN chip was connected to the MCU and not pulled low.

Transmit and receive works now but only with 1 CAN module active. CAN0 and CAN1 work fine independ of echother.
When you enable both CAN0 and CAN1 it will crash:

Exception:Error:
c:/Users/jeroe/AppData/Local/Arduino15/packages/esp32/hardware/esp32/3.1.1/cores/esp32/HWCDC.cpp:610:::0x4080f178:??
0x40030c86: ?? ??:0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/queue.c:1560:::0x40807404:xQueueReceive
0x4081dbc0: ?? ??:0
??:?:::0x4080d554:__global_pointer$
0x4081dca0: ?? ??:0
0x40000aa0: ?? ??:0
0x408160a8: ?? ??:0
0x4081dc0c: ?? ??:0
0x40816150: ?? ??:0
0x4081dc0d: ?? ??:0
0x408160cc: ?? ??:0
0x40812000: ?? ??:0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/riscv/vectors_intc.S:54:::0x40800001:_vector_table
c:/Users/jeroe/Documents/Arduino/libraries/esp32_can-master/src/esp32_can.cpp:9:::0x4080ee58:??
0x4081dbe0: ?? ??:0
0x4081607c: ?? ??:0
0x40811000: ?? ??:0
0x4081dc48: ?? ??:0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/twai/twai.c:699 (discriminator 1):::0x420174c2:twai_receive_v2
0x4081dc00: ?? ??:0
0x4081dc20: ?? ??:0
c:/Users/jeroe/Documents/Arduino/libraries/esp32_can-master/src/esp32_can_builtin.cpp:134:::0x42000a9e:ESP32CAN
0x4081dc40: ?? ??:0
0x4081dc60: ?? ??:0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:258:::0x40807ce0:vPortTaskWrapper
0x4081dc80: ?? ??:0
0x4081dbb0: ?? ??:0
0x4081dcc0: ?? ??:0
0x4080f95c: ?? ??:0
0x4081dcb8: ?? ??:0
0x4080f954: ?? ??:0
0x4081dce0: ?? ??:0
0x4081cca8: ?? ??:0
0x4081dd00: ?? ??:0
0x4081dd20: ?? ??:0
0x40812834: ?? ??:0
0x4081289c: ?? ??:0
0x40812904: ?? ??:0
0x4081dd40: ?? ??:0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/newlib_init.c:43:::0x4200ef18:esp_cleanup_r
0x4081dd60: ?? ??:0
0x4081dd80: ?? ??:0
0x4081dda0: ?? ??:0
0x4081ddc0: ?? ??:0
0x4081dde0: ?? ??:0
0x4081de00: ?? ??:0
0x4081de20: ?? ??:0
0x4081de40: ?? ??:0
0x4081de60: ?? ??:0
0x4081de80: ?? ??:0
0x4081dea0: ?? ??:0
0x4081dec0: ?? ??:0
0x4081dee0: ?? ??:0
0x4081df00: ?? ??:0
0x4081df20: ?? ??:0
0x4081df40: ?? ??:0
0x4081df60: ?? ??:0
0x4081df80: ?? ??:0
0x4081dfa0: ?? ??:0
0x4001975a: ?? ??:0
0x40875720: ?? ??:0
0x4086c110: ?? ??:0
0x4086e610: ?? ??:0

@jeroenveer jeroenveer changed the title Transmit not working after update ArduinoESP32 to v3.1.1 Dual builtin CAN not working on ESP32-C6 Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant