Main Content

MCAN Receive

Read data from CAN 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 block outputs the received values as a 64-by-1 array or an 8-by-1 array for unpacked output type, depending on whether the frame format is CAN-FD or Classic CAN.

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 buffer number.

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 value from the received CAN message.

Dependencies

To enable this port, set Output type to Unpacked.

Data Types: uint32

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

Dependencies

To enable this port, set Output type to Unpacked.

Data Types: uint8

This port outputs the identifier type as:

  • 0 — If its 11-bit standard identifier

  • 1 — If its 29-bit extended identifier

Dependencies

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

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, set the Output type parameter to Unpacked and enable Output frame type.

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 Frame format to Classic CAN, Output type parameter to Unpacked, and enable Output remote parameter.

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 Read source parameter to FIFO 0 or FIFO 1 and enable the Output receive FIFO level.

Data Types: uint8

This port outputs the message read status as:

  • 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.

Note

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 that the MCAN Receive block uses 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 enable 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 enable 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 enable the Bitrate Switching port, which outputs the status of bit rate switching.

Dependencies

To enable this parameter, set the Frame format parameter to CAN-FD and the Output type parameter to Unpacked.

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

Dependencies

To enable this parameter, set Frame format to Classic CAN and Output type parameter to Unpacked.

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

Dependencies

To enable this parameter, set the Read source parameter to FIFO 0 or FIFO 1.

Select this parameter to enable 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