NetBurner 3.5.8
PDF Version
FlexCAN Loopback

Example Path: examples/PlatformSpecific/MODRT1171/CAN/FlexcanLoopback

Overview

The i.MX RT1171's FlexCAN controllers include a loopback self-test mode that connects the transmitter directly to the receiver inside the chip. This example configures one FlexCAN message buffer as a transmitter and another as a receiver with the same CAN ID, sends a frame through the internal loopback interconnect, and prints the payload received on the other side to the serial terminal.

Because the frame never leaves the chip, this example runs on a single bare MODRT1171 – no CAN transceiver, no bus wiring, and no second node. Run it first to verify FlexCAN operation on your module, then move on to the CanSimple and CanErrorMonitor examples, which drive a real CAN bus.

The FlexCAN driver (fsl_flexcan, NXP SDK version 2.7.1) is built into the NetBurner MODRT1171 platform library; the example includes <fsl_flexcan.h> directly and bundles no driver source.

Hardware requirements

  • MODRT1171 module
  • Personal Computer
  • Serial terminal program connected to the MODRT1171 UART0 serial port

Board settings

No special settings are required. Loopback mode uses no package pins.

Note
This example is written for the MODRT1171 rev 1.5 module, and uses FlexCAN1 to match the other MODRT1171 CAN examples. At rev 1.6 (which makes the module a MOD5441X drop-in replacement), the FlexCAN1 signals move from the P1 header to the P2 header: RX moves P1.26 -> P2.41 and TX moves P1.27 -> P2.44. The FlexCAN1 peripheral instance and this example's code are unchanged; only the connector pins move – and this example uses no pins at all. Designs that need more than one CAN bus have options beyond FlexCAN1: FlexCAN3 is available on the I2C pins for designs that do not use I2C (or that bit-bang I2C on spare GPIO), and on rev 1.5 FlexCAN2 also reaches module pins. For pin details see the MODRT1171 Software Developer Guide and the MODRT1171 Pinout Update document: https://www.netburner.com/download/MODRT1171_Rev1p5_to_Rev1p6_Pinout_Update/

Running the demo

Build and load the application, then open the serial terminal. The example sends one frame from transmit message buffer 9 to receive message buffer 10 and prints both payloads:

==FlexCAN loopback functional example -- Start.==
Send message from MB9 to MB10
tx word0 = 0x11223344
tx word1 = 0x55667788
Received message from MB10
rx word0 = 0x11223344
rx word1 = 0x55667788
==FlexCAN loopback functional example -- Finish.==

If the rx words match the tx words, the FlexCAN controller, its clocking, and its interrupt path are all working.