I'm currently in the process of trying to get my Teensy 3.6 to communicate with a preexisting CAN 2.0B device. This device makes use of extended IDs and thus far I've not been able to find any information on datasheets that say one way or the other if the transceivers listed on Collin80's FlexCAN github page support the extended ID format.
I have a few MCP2562s that I purchased from DigiKey a few days ago and they work great with regular 11 bit IDs, I can get back and forth using one of Collin80s examples as well as a simple piece of test code I wrote but as soon as I enable extended IDs on either no communication happens.
Is there something specific I'm missing in datasheets that says "yes this supports extended IDs" or have I just picked the wrong part? Are there parts that other people have tried that work with extended ID's?
Any help is appreciated, thanks!
Collin80's Example Used: https://github.com/collin80/FlexCAN_Library/blob/master/examples/CANTest/CANTest.ino
My Test Code (Please bear with my code, I'm a college student who quickly scratches code together just to see if something will work so this is by no means comprehensive):
I have a few MCP2562s that I purchased from DigiKey a few days ago and they work great with regular 11 bit IDs, I can get back and forth using one of Collin80s examples as well as a simple piece of test code I wrote but as soon as I enable extended IDs on either no communication happens.
Is there something specific I'm missing in datasheets that says "yes this supports extended IDs" or have I just picked the wrong part? Are there parts that other people have tried that work with extended ID's?
Any help is appreciated, thanks!
Collin80's Example Used: https://github.com/collin80/FlexCAN_Library/blob/master/examples/CANTest/CANTest.ino
My Test Code (Please bear with my code, I'm a college student who quickly scratches code together just to see if something will work so this is by no means comprehensive):
Code:
#include <FlexCAN.h>
static CAN_message_t message, received;
#define DEFAULTID 0
void setup() {
delay(1000);
Serial.begin(9600);
while(!Serial)
{
delay(1);
}
Serial.println(F("Setup has begun"));
Can0.begin(1000000);
Can1.begin(1000000);
message.id = 0;
message.ext = 0; //Changing this to 1 breaks everything
message.len = 1;
message.buf[0] = 0;
Serial.println(F("1: Fire Static Message from CAN 0 to CAN 1"));
Serial.println(F("2: Check for Message from CAN 1 to CAN 0"));
Serial.println(F("3: Print data from most recent message from CAN 1 to CAN 0"));
Serial.println(F("4: Fire Static Message from CAN 1 to CAN 0"));
Serial.println(F("5: Check for Message from CAN 0 to CAN 1"));
Serial.println(F("6: Print data from most recent message from CAN 0 to CAN 1"));
Serial.println(F("Setup Complete"));
}
void loop() {
if(Serial.available())
{
char data = (char) Serial.read();
if(data == '1')
{
message.id = DEFAULTID;
Can0.write(message);
Serial.println(F("Message sent from CAN 0 to CAN 1"));
}
else if(data == '2')
{
Serial.print(F("Data available on CAN 0: "));
Serial.println(Can0.available() ? "True" : "False");
}
else if(data == '3')
{
if(Can0.available())
{
Serial.println(F("Reading from CAN 0 message buffer"));
Can0.read(received);
printFrame(received);
}
}
else if(data == '4')
{
message.id = DEFAULTID | 1;
Can1.write(message);
Serial.println(F("Message sent from CAN 1 to CAN 0"));
}
else if(data == '5')
{
Serial.print(F("Data available on CAN 1: "));
Serial.println(Can1.available() ? "True" : "False");
}
else if(data == '6')
{
if(Can1.available())
{
Serial.println(F("Reading from CAN 1 message buffer"));
Can1.read(received);
printFrame(received);
}
}
else
{
Serial.println("NOT A COMMAND");
}
}
delay(1);
}
void printFrame(CAN_message_t &frame)
{
Serial.print("ID: ");
Serial.println(frame.id, HEX);
Serial.println("Available Data");
for(uint8_t i = 0; i < frame.len; i++)
{
Serial.print("Data Element: ");
Serial.print(i);
Serial.print(" = ");
Serial.println(frame.buf[i]);
}
}