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

Thread: CAN Issues with FlexCAN, Teensy 3.2, and Teensy 3.5

  1. #1
    Junior Member
    Join Date
    Feb 2019

    CAN Issues with FlexCAN, Teensy 3.2, and Teensy 3.5


    I am trying to use a Teensy 3.5 with a TI SN65HVD230 3.3V CAN transceiver for a Senior Design project at school.

    I can not for the life of me get the regular, or any of the other sketches I've seen on the internet to work.

    The wiring is straight from the breakout board to the pins on the teensy, no pull up or pull down resistors.

    Here's what I have done:
    • I have verified with an oscilloscope that the transceivers are doing their job. The voltages follow the correct path and deviate away and towards each other like they should.
    • I have verified that the RX and TX pins are correctly aligned, and that the signals are making their way to the correct pins on the teensy
    • I have verified that the sending portion of all the sketches I have tried work, I can see the activity on the bus
    • I have verified that the pins are still operational on each teensy by checking whether or not they can register a high or low digital state.
    • I have tested the bus resistance and it is sitting at 64ohms, within spec according to a troubleshooting guide i found.

    It seems like the receive portion is what I am having trouble with and again, I cannot figure out what's going on.

    • I am using the pawelsky FlexCAN fork.
    • I am using the latest Teensyduino from the site.
    • I am using Arduino 1.8.8

    I have tried a number of different examples, but ill post the CANTest sketch from the FlexCAN library

    // -------------------------------------------------------------
    // CANtest for Teensy 3.1
    // by teachop
    // This test is talking to a single other echo-node on the bus.
    // 6 frames are transmitted and rx frames are counted.
    // Tx and rx are done in a way to force some driver buffering.
    // Serial is used to print the ongoing status.
    #include <Metro.h>
    #include <FlexCAN.h>
    Metro sysTimer = Metro(1);// milliseconds
    int led = 13;
    FlexCAN CANbus(500000);
    static CAN_message_t msg,rxmsg;
    static uint8_t hex[17] = "0123456789abcdef";
    int txCount,rxCount;
    unsigned int txTimer,rxTimer;
    // -------------------------------------------------------------
    static void hexDump(uint8_t dumpLen, uint8_t *bytePtr)
      uint8_t working;
      while( dumpLen-- ) {
        working = *bytePtr++;
        Serial.write( hex[ working>>4 ] );
        Serial.write( hex[ working&15 ] );
    // -------------------------------------------------------------
    void setup(void)
      pinMode(led, OUTPUT);
      digitalWrite(led, 1);
      Serial.println(F("Hello Teensy 3.1 CAN Test."));
    // -------------------------------------------------------------
    void loop(void)
      // service software timers based on Metro tick
      if ( sysTimer.check() ) {
        if ( txTimer ) {
        if ( rxTimer ) {
      // if not time-delayed, read CAN messages and print 1st byte
      if ( !rxTimer ) {
        while ( ) {
          //hexDump( sizeof(rxmsg), (uint8_t *)&rxmsg );
      // insert a time delay between transmissions
      if ( !txTimer ) {
        // if frames were received, print the count
        if ( rxCount ) {
          rxCount = 0;
        txTimer = 100;//milliseconds
        msg.len = 8; = 0x222;
        for( int idx=0; idx<8; ++idx ) {
          msg.buf[idx] = '0'+idx;
        // send 6 at a time to force tx buffering
        txCount = 6;
        digitalWrite(led, 1);
        while ( txCount-- ) {
        digitalWrite(led, 0);
        // time delay to force some rx data queue use
        rxTimer = 3;//milliseconds

  2. #2
    Junior Member
    Join Date
    Feb 2019
    For those who come across this thread.. my issue was this:

    1) I think I had pawelsky's version in my library folder, but Collin's was also installed (I dont know if they are different but most of the examples I've seen aren't compatible with Collin's library I have come to find out...) so I think my Arduino IDE might have been using Collin's.

    When using Collin's library, an object called Can0 is automatically created. This means that using the line
    FlexCAN CANbus(500000);
    in the code above tries to actually create a CAN interface on CAN 1 which the Teensy 3.5 doesn't have.

    For some reason, even if I try to do
    FlexCAN CANbus(0);
    to create a CAN object on interface 0 it does not work for me (the code runs just fine, but any references to do stuff with CANbus yields no results). The only way I can interface with the CAN bus on this chip with this library seems to be through Can0 ONLY.

    Hope this helps the next guy...

Posting Permissions

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