Main Content

MCAN Transmit

Write data to CAN bus

Since R2024b

  • MCAN Transmit block

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

Description

The Modular Controller Area Network (MCAN) transmit block writes data to the CAN bus.

The block accepts a 1-D array of type uint8 when you set the data format to Raw data. If you set the data format to CAN Message, the block accepts Simulink® bus signal from the CAN Pack or CAN FD Pack blocks depending on the frame format.

Examples

Ports

Input

expand all

Specify the messages in the raw data format at this port.

Dependencies

To enable this port, set the Data format parameter to Raw data and disable the Remote transmit parameter.

Data Types: uint8

Specify the remote transmission request at this port as:

  • 1 — To activate the remote transmission request

  • 0 — To deactivate the remote transmission request

Dependencies

To enable this port, set the Data format parameter to Raw data, Frame format parameter to Classic CAN, and enable the Remote transmit parameter.

Data Types: Boolean

Specify the CAN message identifier at this port as one of these values:

  • 0-0x7ff — For a Standard (11-bit) identifier

  • 0-0x1fffffff — For a Extended (29-bit) identifier

Dependencies

To enable this parameter, set the Data format parameter to Raw data and select the Enable input port for identifier parameter.

Data Types: uint32

Specify the CAN message identifier type at this port as one of these values:

  • 0 — If its 11-bit standard identifier

  • 1 or any value other than 0 — If its 29-bit standard identifier

Dependencies

To enable this parameter, set the Data format parameter to Raw data and select the Enable input port for identifier type parameter.

Data Types: uint8

Specify the length of the received CAN message in bytes at this port.

Dependencies

To enable this parameter, set the Data format parameter to Raw data and select the Enable input port for data length parameter.

Data Types: uint8

Specify the messages in the CAN message format.

You can create your messages or you can upload a CAN database file from the CAN Pack or CAN FD Pack blocks depending on the value in the Frame Format parameter.

Note

To create a CAN message using the CAN Pack block, enable the Output as bus parameter in the CAN Pack block.

Dependencies

To enable this port, set the Data format parameter to CAN message.

Data Types: CAN message

Specify the buffer number for CAN transmission.

Dependencies

To enable this port, set the Data format parameter to CAN message, Mode parameter to Buffer, and select the Enable input port for buffer number parameter.

Data Types: uint8

Output

expand all

Specify the data transmission status at this port as one of these values:

  • 0 — No error in CAN data transmission

  • 1 — Error in CAN data transmission due to timeout

  • 2 — Error in CAN data transmission due to invalid buffer configuration

Dependencies

To enable this port, select the Enable status port parameter.

Data Types: uint8

Output port to display the level of FIFO register.

Dependencies

To enable this parameter, set Mode parameter to FIFO or Queue and select Output FIFO transmit free level parameter.

Parameters

expand all

Set the data type of the transmitted message as one of these values:

  • Raw data — To transmit the message as a 1-by-N uint8 array, select Data Format as Raw data.

  • CAN message — To transmit message in CAN message format, set Data Format to CAN message. Depending on the value of Frame Format parameter, use CAN Pack or CAN FD Pack blocks along with the MCAN Transmit block to pack the CAN message.

Note

To create a CAN message using the CAN Pack block, enable the Output as bus parameter in the CAN Pack block.

Select the frame format of the transmitted message.

Select this parameter to transmit a remote frame in the CAN message.

Dependencies

To enable this parameter, set the Data format parameter to Raw data and set the Frame format parameter to Classic CAN.

CAN FD

Select this parameter to enable switching between the nominal bit rate and the data bit rate.

Dependencies

To enable this parameter, set the Data Format parameter to Raw data and Frame format to CAN-FD.

Identifier type

Select this parameter to enable the input port to specify the identifier type.

Dependencies

To enable this parameter, set the Data format parameter to Raw data.

Specify the type of message identifier.

Dependencies

To enable this parameter, set the Data Format parameter to Raw data and disable the Enable input port for identifier type parameter.

Identifier

Select to enable input port for identifier.

Dependencies

To enable this parameter, set Data format parameter to Raw data.

Specify an 11-bit identifier for the standard frame size or a 29-bit one for the extended frame size. You can specify the identifier as a decimal, binary, or hex value. For binary and hex formats, use bin2dec(' '), and hex2dec(' ') respectively to convert the value. The block codes the identifier into a message and sends it the CAN bus.

Dependencies

To enable this parameter, disable the Enable input port for identifier type parameter.

Data length

Select this parameter to enable the input port to specify data length.

Dependencies

To enable this parameter, set the Data format as Raw data.

Specify the data length in bytes.

Dependencies

To enable this parameter, disable the Enable input port for data length parameter.

Node

Specify the number of CAN nodes for data transmission.

Note

The choice of the Number of nodes parameter in the MCAN Transmit block of the Simulink model determines how many nodes you must configure in the MCAN Transmit Peripheral Configuration tool.

Select the mode of the CAN data transmission.

Buffer

Select this parameter to enable the Buffer Number input port in the block.

Dependencies

To enable this parameter, set the Mode parameter to Buffer.

Specify the buffer number for transmit the CAN data.

Dependencies

To enable this parameter, disable the Enable input port for buffer number parameter.

Timeout

Specify the maximum waiting time (in seconds) to transmit the CAN data.

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

Dependencies

To enable this parameter, set Mode parameter to FIFO or Queue.

Select this parameter to enable the Status port, which outputs the data transmission status.

Version History

Introduced in R2024b