Can not receive CAN-Bus Frames with Teensy in conjunction with Waveshare SN65HVD230 C
Hi guys,
I have some basic beginner questions about Teensy 4.0 in conjunction with the FlexCAN_T4 library, since my attempts to read CAN signals have not been successful so far.My experimental setup is as follows:
- Highspeed CAN input (500 kBaud) at the Waveshare SN65HVD230 CAN transceiver board.
- CAN Transceiver Board is connected to a Teensy 4.0: 3.3V --> 3.3V | GND --> GND | CAN-TX --> CAN-RX (Pin 23) | CAN-RX --> CAN-TX (Pin 22)
- 120 Ohm resistor between CAN-H and CAN-L on CAN Transceiver Board
Physically the CAN was also checked by Picoscope -> transmitted signals arrive at CAN-H/CAN-L header
As a basis the read_two_channels - program was used:
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(500000);
}
void loop() {
if ( can1.read(msg) ) {
Serial.print("CAN1 ");
Serial.print("MB: "); Serial.print(msg.mb);
Serial.print(" ID: 0x"); Serial.print(msg.id, HEX );
Serial.print(" EXT: "); Serial.print(msg.flags.extended );
Serial.print(" LEN: "); Serial.print(msg.len);
Serial.print(" DATA: ");
for ( uint8_t i = 0; i < 8; i++ ) {
Serial.print(msg.buf[i]); Serial.print(" ");
}
Serial.print(" TS: "); Serial.println(msg.timestamp);
}
}
Interesting is that my CAN transmitter (restbus simulation from Windows PC) shows a Not Ackknowledge Error, which normally means that there is no receiver on the bus.
The serial output remains empty.
Do I have to set anything else to listen to my CAN messages?
When do I use FIFO, when do I use mailboxes?
What influence do the RX_SIZE and TX_SIZE parameters have?
Do you see any discrepancies in my setup?