Main Content

MCAN Receive

Read data from CAN FD bus

Since R2024b

  • MCAN Receive Block icon

Libraries:
Embedded Coder Support Package for Infineon AURIX TC4x Microcontrollers / AURIX TC4x

Description

The Modular Controller Area Network (MCAN) Receive block reads data from the CAN bus.

The blocks outputs the received values as a 64-by-1 array for unpacked output type in the CAN-FD frame format and a 8-by-1 array for unpacked output type in the Classic CAN frame format.

The blocks outputs a Simulink® bus signal for packed output type. Based on the frame format, use the CAN Unpack or CAN FD Unpack blocks to extract data from the Simulink bus signal.

Examples

Ports

Input

expand all

Specify the number of buffers from which the MCAN Receive block reads the CAN message.

Dependencies

To enable this port, set the Read source parameter to Buffers and select the Enable input port for buffer number parameter.

Data Types: uint8

Output

expand all

The MCAN Receive block outputs the CAN message (data and header) it receives from the Simulink bus signal.

Dependencies

To enable this port, set Output type to Packed.

Data Types: CAN Msg

The block outputs the data read from FIFO 0 register, FIFO 1 register, or buffer, based on the value of Read Source parameter. The maximum size of the data is 8 bytes for Classic CAN and 64 bytes for CAN-FD frame format.

Dependencies

To enable this port, set Output type to Unpacked.

Data Types: uint8

This port outputs a standard or extended ID from the received CAN message.

Dependencies

To enable this port, set Output type to Unpacked.

Data Types: uint32

This port outputs the data length code of the received CAN message in bytes.

N represents the data length code for N number of data bytes.

Dependencies

To enable this port, set Output type to Unpacked.

Data Types: uint8

This port outputs the identifier type as one of these values:

  • 0 — If its 11-bit standard identifier

  • 1 — If its 29-bit extended identifier

Dependencies

To enable this port, select Output identifier type and set the Output type parameter to Unpacked.

Data Types: Boolean

This port outputs the CAN frame data format as:

  • 0 — If it is Classic CAN

  • 1 — If it is CAN-FD

Dependencies

To enable this port, select Output frame type and set the Output type parameter to Unpacked.

Data Types: uint32

This port outputs the status as one of these values:

  • 0 — When the MCAN Receive block receives the CAN FD frames without bit rate switching

  • 1 — When the MCAN Receive block receives the with bit rate switching

Dependencies

To enable this port, set the Frame format parameter to CAN-FD, the Output type parameter to Unpacked, and select the Output bit rate switching parameter.

Data Types: uint8

This port outputs the remote transmission status as one of these values:

  • 1 — If the received CAN message is a remote frame

  • 0 — If the received CAN message is a data frame

Dependencies

To enable this port, set Output type parameter to Unpacked and select Output remote.

Data Types: Boolean

The port outputs the received FIFO fill level.

The FIFO level provides the receive FIFO 0 or FIFO 1 register level after reading the message. Rx FIFO provides how much of Rx FIFO is empty.

Dependencies

To enable this port, set the Output receive FIFO level parameter to Unpacked and select the Output remote.

Data Types: uint8

This port outputs the message read status as one of these values:

  • 1 — If the read CAN message is invalid

  • 0 — If the read CAN message is valid

Dependencies

To enable this port, select the Output Status parameter.

Data Types: uint8

Parameters

expand all

Select the frame type to receive the message.

Specify the read source as FIFO or buffer.

The MCAN Receive block reads the message from FIFO , FIFO 1, or buffer depending on the filter configuration you set in the MCAN Receive Peripheral Configuration.

Specify the buffer number where you want the MCAN Receive block to read the received CAN message.

Dependencies

To enable this parameter, set Read source to Buffers and disable the Enable input port for buffer number parameter.

Select this parameter to enable the input port to specify the buffer number.

Dependencies

To enable this parameter, set Read source to Buffers and select the Enable input port for buffer number parameter.

Specify output type of the MCAN Receive block as Packed or Unpacked.

For unpacked messages, the block outputs different fields of the unpacked CAN message.

For packed messages, the block outputs a Simulink bus signal. To extract data from a Simulink bus signal, depending on the frame format, connect the MCAN Receive block to the CAN Unpack or CAN FD Unpack blocks.

Select this parameter to configure the Id Type port, which outputs the standard or extended message status.

Dependencies

To enable this parameter, set the Output type parameter to Unpacked.

Select this parameter to configure the Frame Type port, which outputs the message frame type.

Dependencies

To enable this parameter, set the Output type parameter to Unpacked.

Select this parameter to configure the Bitrate Switching port, which outputs the status of bit rate switching.

Dependencies

To enable this parameter, set the Frame format parameter to Classic CAN.

Select this parameter to configure the Remote, which outputs the message remote frame status.

Dependencies

To enable this parameter, set the Frame format parameter to Classic CAN.

Select this parameter to configure the FIFO level port, which outputs the received FIFO message level.

Select this parameter to configure the Status port, which outputs the read status.

Specify how often the block receives message, in seconds. When you specify this parameter as -1, Simulink determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2024b