FlexCAN not compiling

mfarver

New member
Arduino 2.3.4 with the latest Teensy libraries I'm having an issue compiling FlexCAN:

In file included from Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\FlexCAN\FlexCAN.cpp:10:
Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\FlexCAN\kinetis_flexcan.h:137: warning: "FLEXCAN1_MCR" redefined
137 | #define FLEXCAN1_MCR (*(vuint32_t*)(FLEXCAN1_BASE))
|
In file included from Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/core_pins.h:32,
from Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/wiring.h:39,
from Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/WProgram.h:46,
from \arduino\sketches\EEBD7E7FF7A01E5DD2C5330FDD90FF98/pch/Arduino.h:6,
from Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\FlexCAN\FlexCAN.h:9,
from Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\FlexCAN\FlexCAN.cpp:9:
Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/imxrt.h:3243: note: this is the location of the previous definition
3243 | #define FLEXCAN1_MCR (IMXRT_FLEXCAN1.offset000)


My code is just trying to bring up the library:
C:
#include <FlexCAN.h>

void setup() {
  Can0.begin(500000); 
}
void loop() { }
 
From the looks of it that library is not intended for use with Teensy 4.x, it hasn't been touched in over 10 years (well before 4.0 came out).
 
Doh, good call. This works much better.

#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;

void setup() {
can1.begin();
can1.setBaudRate(500000);
}
 
Back
Top