#include <FlexCAN_T4.h>
FlexCAN_T4[COLOR="#FF0000"]FD[/COLOR]<[COLOR="#FF0000"]CAN3[/COLOR], RX_SIZE_128, TX_SIZE_128> FD;
void setup(void) {
FD.begin();
[COLOR="#FF0000"] CANFD_timings_t config;
config.clock = CLK_24MHz;
config.baudrate = 1000000;
config.baudrateFD = 2000000;
config.propdelay = 190;
config.bus_length = 1;
config.sample = 70;
FD.setRegions(64);
FD.setBaudRate(config);[/COLOR]
FD.onReceive(canSniff);
FD.enableMBInterrupts();
FD.mailboxStatus();
}
void canSniff(const CANFD_message_t &msg) {
Serial.print("MB "); Serial.print(msg.mb);
Serial.print(" OVERRUN: "); Serial.print(msg.flags.overrun);
Serial.print(" LEN: "); Serial.print(msg.len);
Serial.print(" EXT: "); Serial.print(msg.flags.extended);
Serial.print(" EDL: "); Serial.print(msg.edl );
Serial.print(" TS: "); Serial.print(msg.timestamp);
Serial.print(" ID: "); Serial.print(msg.id, HEX);
Serial.print(" Buffer: ");
for ( uint8_t i = 0; i < msg.len; i++ ) {
Serial.print(msg.buf[i], HEX); Serial.print(" ");
} Serial.println();
}
void loop() {
FD.events();
}
Can you explain why this is? With a short wire connecting can1tx to can1rx it is basically the same as loopback mode, signal looks clean on the scope. I put a 10K pullup to 3.3V (which doesn't appear to change anything).
config.clock = CLK_60MHz;
FlexCAN_T4<CAN2, RX_SIZE_64, TX_SIZE_16> Can_COM1;
void BusCan_InitMB(FlexCAN_T4* BusCan)
{
BusCan->setMBFilter(MB2,0x10AAFF00);
BusCan->enhanceFilter(MB2);
}
void setup()
{
Can_COM1.begin();
Can_COM1.setBaudRate(BAUTRATE_CAN_COM1);
Can_COM1.setMBFilter(REJECT_ALL);
BusCan_InitMeca(&Can_COM1);
}
[ /CODE]
But the template, make me confused...
There is of course error:
- variable or field 'BusCan_InitMB' declared void
- missing template arguments before 'BusCan'
Tonton81, I know it's c++ "tips", but can I abuse more and ask for your lights?