Issues w/ non-stop sending on T4.0 Can3 using FlexCAN_T4 or ACAN_T4

Emach

Member
Hi guys,

I have a T4.0 riding on a custom PCB using a TI TCAN337GDR transceiver. I've tried both ACAN_T4 and the FlexCAN_T4 libraries and see the same behavior using Teensyduino 1.57 in the 2.0.0 IDE and in the 1.8.3 IDE. So I'm guessing it is some underlying library issue or hardware. When I write an outgoing message the message is received by a NeoFire CAN interface and shows up in Vehicle Spy. My problem is it appears the Teensy is non-stop sending at max speed. My event timer in Vehicle Spy shows receiving the message every 254 microseconds! I used the onboard LED to pulse showing how fast I am calling the write function and it pulses at the correct frequency. Running with mailboxes or FIFO doesn't impact the send rate. Any ideas would be greatly appreciated.

Code:
#include <FlexCAN_T4.h>

const byte pinOut_LED = 13;
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> can3;
CAN_message_t msg;

unsigned long t1,t2;

///////////////////////////////////////////////////////////////////////////////////////////////
void setup(void) 
{
  pinMode(pinOut_LED,OUTPUT);
  digitalWrite(pinOut_LED,HIGH);
  Serial.begin(115200);
  can3.begin();
  can3.setBaudRate(500000);

  
  msg.id = 0x123;
  msg.buf[0] = 0x01;
  msg.buf[1] = 0x23;
  msg.buf[2] = 0x45;
  msg.buf[3] = 0x67;
  msg.buf[4] = 0x89;
  msg.buf[5] = 0xAB;
  msg.buf[6] = 0xCD;
  msg.buf[7] = 0xEF;

  t1 = millis();
  t2 = t1;
}
///////////////////////////////////////////////////////////////////////////////////////////////

void loop() 
{
  t1 = millis();

  if((t1-t2) >= 1000)
  {
    can3.write(msg);
    delay(5);
    digitalWrite(pinOut_LED, !digitalRead(pinOut_LED));
    t2 = t1;
  }
 
}
 
Sounds like the Teensy is not receiving an ACK back.

Have you got two 120R terminating resistor in your CAN network ?

Is your NeoFire CAN interface configure as an active node or listen only ?
 
Just verified the 120 Ohm resistor on our board and the NeoFire. When I'm in monitor only mode it sends like a banshee but when I am actively transmitting on the NeoFire I get transmit errors and the NeoFire receives nothing from the T4.
 
Last edited:
You need to configure the NeoFire CAN interface as an active node and not listen only.

Check the NeoFire CAN interface is set for 500kbps.

Your sketch is working on my system.
 
Thanks for trying it. Had another board populated and the code runs fine. Something wonky with the transceiver on the first board.
 
Back
Top