Uncertain behavior of Teensy 4.0 board

revati

Active member
Hi all,

I am working on teensy 4.0 board communicating with CAN controller. First when i tried to communicate between 2 CAN controllers I was able to read and write message through CAN controller .but again i am trying to do i am not able to achieve desired output what can be reason? I have connected CANH and CANL with each other respectively. 60ohm termination is also there in between two wires. Anything i am pending from my side please do let me know

Thanks,
Revati.
 
It is almost impossible to provide any kind of guidance or advice without seeing both, how you have your components wired up (pictures that clearly allow wired connections to be traced are best), and the code that you are testing with (paste into your message using the CODE tags that look like this "</>" right above the message composition area). Without knowing specifics about your wiring & sketch, only blind guesses would be possible.

Also, is this the same problem that you have already posted about in <this> thread ?? If so, starting multiple threads on the same topic is strongly discouraged. If this is the same problem, please continue this discussion on the other thread.

Mark J Culross
KD5RXT
 
This code i am flashing on teensy 4.0 board
Code:
#include <FlexCAN_T4.h>

FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can1;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> Can2;
static CAN_message_t msg;
static CAN_message_t inMsg;


void setup(void)
{
  Serial.begin(115200);
  // delay(2000);
  Can1.begin();
  Can2.begin();
  Can1.setBaudRate(500000);
  Can2.setBaudRate(500000);
  msg.id = 0x04000001;
  msg.len = 8;
  msg.flags.extended = 1;
  msg.buf[0] = 10;
  msg.buf[1] = 20;
  msg.buf[2] = 0;
  msg.buf[3] = 100;
  msg.buf[4] = 128;
  msg.buf[5] = 64;
  msg.buf[6] = 32;
  msg.buf[7] = 16;

}

// -------------------------------------------------------------

void loop(void)
{

  msg.buf[0]++;
  int fd = Can1.write(msg);
  if (fd)
  {
    Serial.println("sent");
  }
  else
    Serial.print("fail");

  CAN_message_t inMsg;
  Serial.printf("%s", &inMsg);
  if (Can2.read(inMsg) != 0)
  {
    Serial.print("Received CAN ID on can1:  0x");
    Serial.printf("%08X\n", inMsg.id);
    process_canid(&inMsg);
  }

  delay(1000);
}
 
Put these lines:
Code:
msg.id = 0x04000001;
  msg.len = 8;
  msg.flags.extended = 1;
  msg.buf[0] = 10;
  msg.buf[1] = 20;
  msg.buf[2] = 0;
  msg.buf[3] = 100;
  msg.buf[4] = 128;
  msg.buf[5] = 64;
  msg.buf[6] = 32;
  msg.buf[7] = 16;

Right before Can1.write(msg);
 
Back
Top