MCAN internal loopback
This example demonstrates MCAN communication using internal loopback mode. The application configures the MCAN module to transmit and receive messages internally, allowing verification of the CAN controller functionality without requiring external connections. The sent message is received by the same node through the internal loopback path.
Example Usage
Build and run the example after connecting to the device.
The application initializes the MCAN module with:
Internal loopback mode enabled
Standard CAN message format
The transmitter sends test messages with incrementing data.
The receiver captures the looped-back messages internally.
The application verifies that the received data matches the transmitted data.
txMsg.data[0] is updated with the current value of gMsgCount before each transmission to confirm new data is being transmitted and received.
A breakpoint will be hit if an error is encountered; check the gError variable for status.
Key features demonstrated:
MCAN configuration for internal loopback
CAN message transmission and reception
Loopback validation without external hardware
Error detection and reporting
Peripherals & Pin Assignments
Peripheral |
Pin |
Function |
|---|---|---|
MCAN0 |
PA11 |
RX Pin |
MCAN0 |
PA12 |
TX Pin |
Note: No external connections are required for this internal loopback example.