Teensy3.6 CANFD - How to communicate via CAN2.0B interface?

Status
Not open for further replies.

ibo

Member
Hello,

I'm newbie here, and working on:
- two Teensy3.6 CANFD (http://skpang.co.uk/catalog/teensy-...-breakout-board-include-teensy-36-p-1550.html).
- using this software demo (https://github.com/skpang/Teensy36_with_mcp2517FD_CAN_FD_demo).

I could setup a CAN network between two of Teensy3.6 and send CAN FD frames, via the CANFD interface.

Now:
I removed all wires and let only the CAN2.0B interfaces being connected, and activated the two 120Ohm transistors.
But how can I send the classic CAN frames via this CAN2.0B interface? And what exactly should I configure on these two devices?

I tried changing the operation mode to CAN_CLASSIC_MODE in both devices, and marked the FDF of the transmitted message object as 0. In addition, I tried to set the MAX_DATA_BYTES as 8 and the DLC as well, according to the restriction of classic CAN. But the receiver device didn't receive anything.

Cheers,
Ibo
 
From the photo, you are using the Teensy CAN. You cannot use the MCP2517FD driver.

Just use the FlexCAN driver.

Code:
#include <FlexCAN.h>

uint32_t can_msg_count = 0;
CAN_message_t msg,rxmsg;

void setup() {

  delay(1000);
  Can1.begin(500000); //set speed here. 
 
   
}


void loop() {
  
 
  msg.len = 8;
  msg.id = 0x7DF;
  msg.buf[0] = can_msg_count++;
  msg.buf[1] = 0x01;
  msg.buf[2] = 0x0c;
  msg.buf[3] = 0;

  Can1.write(msg);
  
  delay(1000);

}
 
To read the message:

Code:
void loop() {
  
 
  msg.len = 8;
  msg.id = 0x7DF;
  msg.buf[0] = can_msg_count++;
  msg.buf[1] = 0x01;
  msg.buf[2] = 0x0c;
  msg.buf[3] = 0;

  Can1.write(msg);
  
  while(Can1.read(rxmsg))
  { 
     String CANStr(""); 
     for (int i=0; i < rxmsg.len; i++) {     

         CANStr += String(rxmsg.buf[i],HEX);
         CANStr += (" ") ;
     }
     Serial.print(rxmsg.id,HEX); 
     Serial.print(' '); 
     Serial.print(rxmsg.len,HEX); 
     Serial.print(' ');
     Serial.println(CANStr);  
        
  }
  delay(1000);

}
 
From the photo, you are using the Teensy CAN. You cannot use the MCP2517FD driver.
I beg your pardon, your reply is not clear to me.

Why can't I use the MCP2517FD controller? I thought, I'm communicating with this chip through SPI.

In addition, I'm using the above demo to send and receive CAN frames via CANFD interface without any problem. But I don't know how to make the communication goes through CAN2.0B interface.

Cheers,
Ibo
 
Your board has two green connectors. One marked CAN FD which is connected to the MCP2517FD controller then to the teensy via SPI.

The other green connector which you have wired up is connected to the Teensy 3.6 via a CAN transceiver. It is not connected to the MCP2517FD controller.

That is why you have to use Flexcan driver and not the MCP2517FD driver.
 
Your board has two green connectors. One marked CAN FD which is connected to the MCP2517FD controller then to the teensy via SPI.

The other green connector which you have wired up is connected to the Teensy 3.6 via a CAN transceiver. It is not connected to the MCP2517FD controller.

That is why you have to use Flexcan driver and not the MCP2517FD driver.
Aha, now it is clear why I shouldn't use MCP2517FD.

I did use the FlexCAN and it works.

Thank you for your help,
Ibo
 
CANFD can work in CAN2.0 mode as well as long as you keep the payload length to 8 bytes and don’t use baud rate switching for data.
 
CANFD can work in CAN2.0 mode as well as long as you keep the payload length to 8 bytes and don’t use baud rate switching for data.
Thank you for the reply. This wasn't actually the problem that I have mentioned, but I might do that eventually. I will look into it later.

Cheers, Ibo
 
Status
Not open for further replies.
Back
Top