FlexCAN_T4 Send Extended CAN ID Message

Status
Not open for further replies.

sirhannick

New member
Hi All-
I am working on a project where I am trying to send and received CAN messages with extended ID's. I am using a Teensy 4.0 with the FlexCAN_T4 library. The problem I am having is getting the library to switch from standard ID's to extended. Also the message data is incorrect along with the DLC. I am looking to get the CAN ID of 0x18FEDF00, but the Teensy is sending 0x63F instead. Any suggestions on making the library switch? I hope I'm just missing something simple. Take a look at the screenshot to see the traffic on CAN as seen from Vector CANalyzer.

Code:
#include <FlexCAN_T4.h>

FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
CAN_message_t msg;

void setup(void) {
  can1.begin();
  can1.setBaudRate(250000);
}

void loop() 
{
  msg.flags.extended = 1;
  msg.id = 0x18FEDF00;
  msg.len = 8;
  msg.buf[0] = 55;
  msg.buf[1] = 0;
  msg.buf[2] = 0;
  msg.buf[3] = 0;
  msg.buf[4] = 0;
  msg.buf[5] = 0;
  msg.buf[6] = 0;
  msg.buf[7] = 0;
  can1.write(msg);
  delay(500);
}

can_extended.jpg
 
Status
Not open for further replies.
Back
Top