Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

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

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    5

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

    Hello,

    I'm newbie here, and working on:
    - two Teensy3.6 CANFD (http://skpang.co.uk/catalog/teensy-3...36-p-1550.html).
    - using this software demo (https://github.com/skpang/Teensy36_w...FD_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

  2. #2
    Can you clarify your setup.

    Are you using the CAN on board the Teensy3.6 ?

  3. #3
    Junior Member
    Join Date
    Mar 2019
    Posts
    5
    Hi,
    Basically, I have two Teensy3.6CANFD,and I connected their CAN2.0B interfaces with wires. I activated their 120Ohm by jumpers.
    Here a photo of my setup: https://pasteboard.co/I5fAwqo.jpg

    Cheers,
    Ibo

  4. #4
    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);
    
    }

  5. #5
    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);
    
    }

  6. #6
    Junior Member
    Join Date
    Mar 2019
    Posts
    5
    Quote Originally Posted by skpang View Post
    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

  7. #7
    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.

  8. #8
    Junior Member
    Join Date
    Mar 2019
    Posts
    5
    Quote Originally Posted by skpang View Post
    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

  9. #9
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,136
    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.

  10. #10
    Junior Member
    Join Date
    Mar 2019
    Posts
    5
    Quote Originally Posted by tonton81 View Post
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •