SK Pang Triple CAN board - baudrate limited to 500MHz? faster?

Status
Not open for further replies.

bschena

Active member
I'm using CAN1 on the SKPang Triple CAN board here, http://skpang.co.uk/catalog/teensy-41-triple-can-board-with-240x240-ips-lcd-p-1592.html

CAN transceiver is MCP2562-E/SN, if that matters.

I can only seem to run the CAN (2.0B) at 500MHz, anything faster and it just locks up.

Code:
can1.setBaudRate(500000);

My understanding is that CAN2.0 should be able to run at 1GHz. Can anyone confirm my understanding, or does anyone know if the SKPang board can run faster?

Thanks!
 
can you post your sketch code? its kbps not MHz, and I use his board

i didnt think a 600mhz cpu could handle a 1ghz bus :)
 
Last edited:
can you post your sketch code? its kbps not MHz, and I use his board

i didnt think a 600mhz cpu could handle a 1ghz bus :)

Ha, yes, I had some late-night-cognitive-dissonance when I wrote that. Of course, kbps, not MHz. Glad you understood what I meant, not what I said.

My loopback test code:

Code:
/*
 *  Loopback test: CAN1 connected to CAN2 
 *  
   Based on demo sketch: Teensy41_240x240_LCD_CANFD from SK Pang.
   for this board: http://skpang.co.uk/catalog/teensy-41-triple-can-board-with-240x240-ips-lcd-p-1592.html

   v1: Modified to remove the FD stuff. Runs with CAN1 looped back to CAN2 (H to H, L to L)
   v2: send messages from CAN1 to CAN2, read and display packet contents from CAN2 receive
   v3: clean up unused FD stuff

*/

#include <FlexCAN_T4.h>
#include <SPI.h>

// Create CAN1 instance
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;

IntervalTimer timer;
uint8_t d = 0;

void setup(void) {
  Serial.begin(115200); delay(1000);
  Serial.println("Test CAN1 to RMD");

  can1.begin();
  can1.setBaudRate(500000);   // start with 500kbps, try 1Mbit/s later (note: does not work at 1M)
  can1.setMBFilter(ACCEPT_ALL);
  can1.distribute();
  can1.mailboxStatus();

  can2.begin();
  can2.setBaudRate(500000);
  can2.setMBFilter(ACCEPT_ALL);
  can2.distribute();
  can2.mailboxStatus();

  timer.begin(sendframe, 1000000); // Send frame every 1s (calls sendframe())
}

void sendframe()  // triggered by timer
{
  Serial.println("sending msg1");
  CAN_message_t msg1;
  msg1.id = 0x141;  // Message ID = 0x140 + NodeID (as set by DIP switches on motor) - typically "1"
  msg1.buf[0] = 0x9A; //0x90 - read encoder data command, 0x9A - read motor status
  msg1.buf[1] = 0x01;
  msg1.buf[2] = 0x02;
  msg1.buf[3] = 0x03;
  msg1.buf[4] = 0x04;
  msg1.buf[5] = 0x05;
  msg1.buf[6] = 0x06;
  msg1.buf[7] = 0x07;
  can1.write(msg1);
}

void loop() {
  CAN_message_t msgcan2;

  if (can2.read(msgcan2))
  { /* check if we received a CAN frame */
    Serial.println("Got can2");
    //      Serial.print("MB: "); Serial.print(msgcan2.mb);
    //      Serial.print("  OVERRUN: "); Serial.print(msgcan2.flags.overrun);
    Serial.print("  ID: 0x"); Serial.print(msgcan2.id, HEX );
    //      Serial.print("  EXT: "); Serial.print(msgcan2.flags.extended );
    //      Serial.print("  LEN: "); Serial.print(msgcan2.len);

    Serial.print(" DATA: ");
    for ( uint8_t i = 0; i < msgcan2.len ; i++ ) {
      Serial.print(msgcan2.buf[i]); Serial.print(" ");
    }
    Serial.print("  TS: "); Serial.println(msgcan2.timestamp);
  }
}

I emailed SKPang - they suggested adding the 120ohm termination resistor on their board in order to get to 1Mbit/s. I assumed that their end would have the resistor installed; apparently it does not. The device on the far end of my CAN bus does have a switchable one.
 
that and also try changing clock using setClock(), default is 24mhz on T4, 16 on T3, and I use 60mhz in car. 24mhz didnt work well on honda's 125kbps possible arbitration timing with clock, but after switching to peripheral 60mhz then 125kbps worked fine. the FD version allows multiple timings per bus speed on the same clock, so theres more timings to choose from. the CAN2.0 is calculated per controller clock rate.
 
that and also try changing clock using setClock(), default is 24mhz on T4, 16 on T3, and I use 60mhz in car. 24mhz didnt work well on honda's 125kbps possible arbitration timing with clock, but after switching to peripheral 60mhz then 125kbps worked fine. the FD version allows multiple timings per bus speed on the same clock, so theres more timings to choose from. the CAN2.0 is calculated per controller clock rate.

Thanks tonton81. I added the resistor and 1Mbits/sec works now. Thanks for the setClock() tip - I'll play with that if I run into reliability issues with the faster setting.

Code:
 can1.setBaudRate(1000000);   // start with 500kbits/sec (500000), 1Mbits/sec (1000000) works now with termination resistor
 
Status
Not open for further replies.
Back
Top