ThomasB wrote:Merged
About the CAN controller.
-
- Posts: 14
- Joined: Sun Jan 03, 2016 12:15 am
Re: About the CAN controller.
Successfully built with thanks!
Re: About the CAN controller.
Hi,
i can now build the project. Thanks!
Now i have another issue. I'm using then pins 4 and 5. CAN_init() and CAN_write_frame(&__TX_frame) both return 0, so i think i'm good here. The problem is, that i'm not able to see any signals on pin 5 (using an logic analyser directly connected to TX). Any idea what could be going wrong?
Thanks
i can now build the project. Thanks!
Now i have another issue. I'm using then pins 4 and 5. CAN_init() and CAN_write_frame(&__TX_frame) both return 0, so i think i'm good here. The problem is, that i'm not able to see any signals on pin 5 (using an logic analyser directly connected to TX). Any idea what could be going wrong?
Thanks
Re: About the CAN controller.
Hi again,
all is working now. It was just a wiring issue.
Thanks again an keep up the great work!
all is working now. It was just a wiring issue.
Thanks again an keep up the great work!
-
- Posts: 14
- Joined: Sun Jan 03, 2016 12:15 am
Re: About the CAN controller.
Things didn't go that well on me.
I've built the PCB with Texas Instrument SN65HVD232, and got the code built, and measured the CAN_H and CAN_L in recessive state of 2.285V so I believe there are no power issues.
Running Rudi's main file, and when I try:
ESPCan configured by this Data:
Node : 0x264
CAN RXD PIN NUM: 4
CAN TXD PIN NUM: 5
the error is attached, and when I switch to:
ESPCan configured by this Data:
Node : 0x264
CAN RXD PIN NUM: 16
CAN TXD PIN NUM: 5
The situation gets worse. Any hits?
Error message:
I've built the PCB with Texas Instrument SN65HVD232, and got the code built, and measured the CAN_H and CAN_L in recessive state of 2.285V so I believe there are no power issues.
Running Rudi's main file, and when I try:
ESPCan configured by this Data:
Node : 0x264
CAN RXD PIN NUM: 4
CAN TXD PIN NUM: 5
the error is attached, and when I switch to:
ESPCan configured by this Data:
Node : 0x264
CAN RXD PIN NUM: 16
CAN TXD PIN NUM: 5
The situation gets worse. Any hits?
Error message:
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
Re: About the CAN controller.
@beck
could you manage and have you find the mistake in the code line 75 in the file "main_rubi.c"
best wishes
rudi
could you manage and have you find the mistake in the code line 75 in the file "main_rubi.c"
Code: Select all
/Users/Beck/Developer/esp/can_bus_components/main/./main_rubi.c:75
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: About the CAN controller.
@thomas
revised CAN Demo based on the ESP-IDF Component CAN Driver pack is in the pipe
i must look how a PR is done from a branch... comes to yours ...
in the meantime folks, have a look here too
best wishes
rudi
revised CAN Demo based on the ESP-IDF Component CAN Driver pack is in the pipe
i must look how a PR is done from a branch... comes to yours ...
in the meantime folks, have a look here too
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: About the CAN controller.
plexidj wrote:....
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); }
Hello plexidj, I'm trying to copy what you did in Arduino without any success. If you are still monitoring this thread, could you please share your ino file for the ESP32? Or is it the same sketch you posted for the Arduino? Did you have to modify the CAN driver files any? like change include directive for your directory structure?
Did you get this error at all:
CAN.cpp:58:32: error: invalid conversion from 'uint32_t {aka unsigned int}' to '__CAN_IRQ_t' [-fpermissive]
interrupt = MODULE_CAN->IR.U;
Thanks,
Rey
-
- Posts: 22
- Joined: Tue Oct 10, 2017 2:46 pm
Re: About the CAN controller.
Should I be able to get output on the TX pin without having connected a tranceiver? I can't get anything out of CAN_write_frame();:
All I get is a high level on TX and a low level on RX.
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);
Re: About the CAN controller.
Hi DrSegatron
If the CAN controller sees a low level at the Rx Pin, it thinks the bus is in the dominant state, thus occupied and doesn't send anything. Furthermore the CAN Controller expects its Tx signal to be looped back by the transceiver. So if you don't have a transceiver connected, try to short the Tx and Rx pin. - worked at my place.
-_scrat
If the CAN controller sees a low level at the Rx Pin, it thinks the bus is in the dominant state, thus occupied and doesn't send anything. Furthermore the CAN Controller expects its Tx signal to be looped back by the transceiver. So if you don't have a transceiver connected, try to short the Tx and Rx pin. - worked at my place.
-_scrat
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 72 guests