HAL MCAN FIFO Loopback Polling

This example demonstrates CAN FD communication using the MCAN HAL module in internal loopback mode with polling-based TX and RX handling. No external CAN bus or transceiver is required.

Overview

The application transmits 10 CAN FD frames through the TX FIFO and receives them back through RX FIFO 0 using a standard ID filter. Each received frame is verified against the transmitted payload. A pass/fail summary is printed to the terminal on completion.

Configuration

Parameter

Value

CAN mode

CAN FD (64-byte payload)

Loopback mode

Internal

TX path

TX FIFO (4 elements)

RX path

RX FIFO 0 (4 elements)

Standard ID filter

DUAL filter, exact match on APP_MCAN_STD_ID -> RX FIFO 0

Non-matching frames

Rejected

Processing mode

Polling

Nominal bit rate

500 kbps (40 MHz clock, prescaler=1, tseg1=67, tseg2=12, sjw=6, SP=85%)

Data bit rate

1 Mbps (40 MHz clock, prescaler=1, tseg1=31, tseg2=8, sjw=4, SP=80%)

External Connections

None required. Internal loopback mode connects the TX output back to the RX input inside the MCAN IP. The TX pin is held recessive and no signal appears on the external CAN bus.

Expected Output

MCAN HAL FIFO Loopback Polling Example Started Message 1/10: OK Message 2/10: OK … Message 10/10: OK

[SUMMARY] Example PASS !