Re: About the CAN controller.
Posted: Mon May 22, 2017 2:32 am
Successfully built with thanks!
Merged
Merged
Code: Select all
Guru Meditation Error of type InstrFetchProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0xffffffff PS : 0x00060430 A0 : 0x800d06f5 A1 : 0x3ffb8880
A2 : 0x00000800 A3 : 0xffffffff A4 : 0x00060023 A5 : 0x3ffaf79c
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x8010fbbd A9 : 0x3ffb8830
A10 : 0x4010f9cc A11 : 0x3f407890 A12 : 0x00000800 A13 : 0x00000000
0x4010f9cc: task_CAN at /Users/Beck/Developer/esp/can_bus_components/main/./main_rubi.c:75
A14 : 0x00000005 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x00000014
EXCVADDR: 0xfffffffc LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Backtrace: 0x7fffffff:0x3ffb8880 0x400d06f5:0x3ffb8950
0x400d06f5: main_task at /Users/Beck/Developer/esp/esp-idf/components/esp32/./cpu_start.c:307
Guru Meditation Error of type IllegalInstruction occurred on core 1. Exception was unhandled.
Register dump:
PC : 0x401109e8 PS : 0x00060030 A0 : 0x80110755 A1 : 0x3ffc57f0
0x401109e8: gpio_set_direction at /Users/Beck/Developer/esp/esp-idf/components/driver/./gpio.c:250
A2 : 0x00000005 A3 : 0x00000002 A4 : 0x3ffc5a9c A5 : 0x00000000
A6 : 0x3ffc5a50 A7 : 0x00060b20 A8 : 0x00000021 A9 : 0x3ffc57e0
A10 : 0x00000001 A11 : 0x00000001 A12 : 0x3ffc5a98 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00060b23 SAR : 0x00000000 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x401109e8:0x3ffc57f0 0x40110755:0x3ffc5820 0x4010f9e4:0x3ffc5840
0x401109e8: gpio_set_direction at /Users/Beck/Developer/esp/esp-idf/components/driver/./gpio.c:250
0x40110755: CAN_init at /Users/Beck/Developer/esp/can_bus_components/components/can/./CAN.c:175
0x4010f9e4: task_CAN at /Users/Beck/Developer/esp/can_bus_components/main/./main_rubi.c:89
Code: Select all
/Users/Beck/Developer/esp/can_bus_components/main/./main_rubi.c:75
....
To use the driver in the Arduino environment I rearranged the folder structure a little bit, removed the "cfg" folder including CAN_config.c file and renamed CAN.c to CAN.cpp. It now looks like:
Code: Select all
[folder] library [folder] CAN_ESP32 [file] CAN.cpp [file] CAN.h [folder] incude [file] CAN_config.h [file] can_regdef.h
.....
The Arduino ino file looks like:....Code: Select all
#include "CAN.h" CAN_device_t CAN_cfg = { .speed=CAN_SPEED_500KBPS, // CAN Node baudrade .tx_pin_id = GPIO_NUM_5, // CAN TX pin .rx_pin_id = GPIO_NUM_4, // CAN RX pin .rx_queue=NULL, // FreeRTOS queue for RX frames }; CAN_frame_t frame; CAN_frame_t __RX_frame; long t_old; void setup() { // put your setup code here, to run once: Serial.begin(500000); //create CAN RX Queue CAN_cfg.rx_queue = xQueueCreate(10,sizeof(CAN_frame_t)); //start CAN Module CAN_init(); } void loop() { // put your main code here, to run repeatedly: if ((millis()-t_old)>1000){ t_old=millis(); frame.MsgID=0x3ff; frame.DLC=8; frame.data.u8[0]='C'; frame.data.u8[1]='A'; frame.data.u8[2]='N'; frame.data.u8[3]='E'; frame.data.u8[4]='S'; frame.data.u8[5]='P'; frame.data.u8[6]='3'; frame.data.u8[7]='2'; CAN_write_frame(&frame); } if(xQueueReceive(CAN_cfg.rx_queue,&__RX_frame, 3*portTICK_PERIOD_MS)==pdTRUE){ Serial.print(millis()); Serial.print("/"); Serial.print(String(__RX_frame.MsgID,HEX)); Serial.print((char)__RX_frame.data.u8[0]); Serial.print((char)__RX_frame.data.u8[1]); Serial.print((char)__RX_frame.data.u8[2]); Serial.print((char)__RX_frame.data.u8[3]); Serial.print((char)__RX_frame.data.u8[4]); Serial.print((char)__RX_frame.data.u8[5]); Serial.print((char)__RX_frame.data.u8[6]); Serial.println((char)__RX_frame.data.u8[7]); } delay(0); }
CAN.cpp:58:32: error: invalid conversion from 'uint32_t {aka unsigned int}' to '__CAN_IRQ_t' [-fpermissive]
interrupt = MODULE_CAN->IR.U;
Code: Select all
CAN_device_t CAN_cfg =
{
.speed=CAN_SPEED_125KBPS, // CAN Node baudrade
.tx_pin_id = GPIO_NUM_5, // CAN TX pin
.rx_pin_id = GPIO_NUM_4, // CAN RX pin
.rx_queue=0, // FreeRTOS queue for RX frames
};
Code: Select all
CAN_init();
while (1)
{
tx.FIR.B.FF=CAN_frame_std;
tx.FIR.B.RTR=CAN_no_RTR;
tx.FIR.B.DLC=8;
tx.MsgID=CONFIG_ESP_CAN_NODE_ITSELF;
tx.data.u32[0]=0xaaaaaaaa;
tx.data.u32[1]=0x55555555;
CAN_write_frame(&tx);