|
NetBurner 3.5.8
PDF Version |
Example Path: examples/PlatformSpecific/MODRT1171/CAN/CanFdSimple
This example turns the MODRT1171 into an interactive CAN FD node on FlexCAN1, the module's primary CAN bus. CAN FD (Flexible Data-rate) extends classic CAN with payloads up to 64 bytes per frame and, with bit-rate switching (BRS), a data phase that runs faster than the arbitration phase. This node arbitrates at 500 kbit/s and switches to 2 Mbit/s for the data phase of BRS frames.
A receive task prints every frame seen on the bus – classic or FD – with the FD flags decoded (EDL = FD frame, BRS = bit-rate switch, ESI = error state indicator), and a serial menu sends classic frames, FD frames with BRS, and FD frames without BRS, so you can watch each variant on a bus analyzer or a second node.
An FD node receives and transmits classic frames as well – one FD message buffer carries both types – so this example doubles as a general bus monitor. Every node on a bus carrying FD frames should be FD-capable.
The FlexCAN driver (fsl_flexcan, NXP SDK version 2.11.6) is built into the NetBurner MODRT1171 platform library; the example includes <fsl_flexcan.h> directly and bundles no driver source.
Wire the FlexCAN1 signals to your transceiver's TXD/RXD pins:
| Signal | Module pin (rev 1.5) | Transceiver pin |
|---|---|---|
| FlexCAN1 RX | P1.26 | RXD |
| FlexCAN1 TX | P1.27 | TXD |
Connect the transceiver's CANH/CANL to the bus, and remember the 120 ohm termination resistors at both ends of the bus.
Build and load the application, then open the serial terminal:
Press 'S', 'F', or 'D' to transmit; frames from other nodes print as they arrive, with the frame type decoded:
A CAN transmission is only complete once another node acknowledges it. If you press a send key with no transceiver or second node attached, the controller keeps retransmitting the frame, the transmit buffer stays busy, and further sends are refused with an explanatory message – press 'A' to abort the pending frame, and 'T' to watch the error counters. The CanErrorMonitor example explores the error states in depth.
To verify CAN FD operation on a single module with no external hardware – including a measured classic-vs-FD throughput comparison – run the CanFdLoopback example first. For the classic CAN version of this node, see CanSimple.