HAL MCAN FIFO Loopback Interrupt

This example demonstrates CAN FD communication using the MCAN HAL module in internal loopback mode with fully interrupt-driven 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. Both TX completion and RX reception are signalled entirely through interrupts.

Configuration

Parameter

Value

CAN mode

CAN FD (64-byte payload)

Loopback mode

Internal

TX path

TX FIFO (4 elements)

TX Event FIFO

4 elements (used for TX confirmation interrupt)

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

TX processing mode

Interrupt (MCAN_IR.TEFN — TX Event FIFO new entry)

RX processing mode

Interrupt (MCAN_IR.RF0N — RX FIFO 0 new message)

CPU interrupt

MCAN0_INT_IRQn (Line 0)

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 Interrupt Example Started Message 1/10: OK Message 2/10: OK … Message 10/10: OK

[SUMMARY] Example PASS !