tonton81 / FlexCAN_T4

FlexCAN (CAN 2.0 / CANFD) Library for Teensy 3.x and 4.0
https://forum.pjrc.com/threads/56035-FlexCAN_T4-FlexCAN-for-Teensy-4
MIT License
195 stars 65 forks source link

CANFD #3

Closed khalm-github closed 3 years ago

khalm-github commented 4 years ago

Hi, i am not expert of teensy and i was excited to use its CANFD but i got upset. i set two nodes (TX and RX), i am using MCP2562FD transceiver, i uploaded the example for the two board without any problems, but i got nothing on the can line, also i got nothing on the serial monitor. i am working for 3 days on that and i could not find where is the problem, i review the wiring many times and its look like right, did i forget something ! or someone faced the same issues before ! This is what i see on the serial monitor of the receiver Capture0

i used this code for receiving RX

and this for transmitting TX

i followed this diagram for wiring, but i connected STBY pin of the transceiver just to the ground! wiring

tonton81 commented 4 years ago

In setup(), you need to define a callback and interrupts:

FD.onReceive(canSniff); FD.enableMBInterrupts();

Then in loop() you need to enable the data buffer: FD.events();

Then make sure your callback exists:

void canSniff(const CANFD_message_t &msg) { Serial.println("Interrupted"); Serial.print("MB "); Serial.print(msg.mb); Serial.print(" OVERRUN: "); Serial.print(msg.flags.overrun); Serial.print(" LEN: "); Serial.print(msg.len); Serial.print(" EXT: "); Serial.print(msg.flags.extended); Serial.print(" TS: "); Serial.print(msg.timestamp); Serial.print(" ID: "); Serial.print(msg.id, HEX); Serial.print(" Buffer: "); for ( uint8_t i = 0; i < msg.len; i++ ) { Serial.print(msg.buf[i], HEX); Serial.print(" "); } Serial.println(); }

The demo code on here is from the beta days and has to be updated to reflect changes, but these instructions have been updated on the forum posts and readme

khalm-github commented 4 years ago

Thanks you very much for your quick response, but its still no big difference. i would be thankful if you notice me about any other thing may cause this issue .

now my TX code is like that: TX

i added FD.enableMBInterrupts(); inside setup of TX, but does not make any change.

and RX code:

RX

and on the serial monitor just a white screen

Capture0

i removed CANFD_message_t msg; from inside loop() but also does not make any change.

Is there anything else that may be i did wrong !

tonton81 commented 4 years ago

Is your transceiver enabled? If not you need to drive the line LOW to enable it

ALSO, begin() MUST be called BEFORE any other FD. calls, thats why it's blank because you didn't call begin to initialize the registers

Hint, look at onReceive and enableMBInterrupts

khalm-github commented 4 years ago

i will check that again tomorrow because i leaved now then i will back another hint; what do you mean by drive the line low, i think the UART take control of all pins after serial.begin(), or do you mean something else !

tonton81 commented 4 years ago

The transceiver enable pin, dont know if yours has one or not, didnt have time to check the datasheet of it, but for sure begin() has to be absolutely called first before the rest

khalm-github commented 4 years ago

no my transciever does not have enable pin. tomorrow i will check again the code, thanks Sir

This is my transciever MCP2562FD from microship

MCP2562FD

khalm-github commented 4 years ago

Hi, i modified the code as you mention, and now i got the old output again.

Capture0

i really wondering why it does not work! should i replace the transceiver with another type.

also i disconnect the transceiver and connect the rx and tx pins 30 and 31 for teensy on the oscilloscope and i got signal

tonton81 commented 4 years ago

Check if the transceiver CANH and CANL lines are parallel between each Teensy, and that both Teensies share a common ground path

tonton81 commented 4 years ago

Did you get up and running in CANFD mode yet? I've posted examples of TeensyCAN running CANFD in 8Mbps mode talking between nodes, perhaps you can use that to rule out software issue to check the wiring setup