FDCAN Write
Libraries:
STM32 Microcontroller Blockset /
STM32G0xx Based Boards
STM32 Microcontroller Blockset /
STM32G4xx Based Boards
STM32 Microcontroller Blockset /
STM32H5xx Based Boards
STM32 Microcontroller Blockset /
STM32H7xx Based Boards
STM32 Microcontroller Blockset /
STM32L5xx Based Boards
STM32 Microcontroller Blockset /
STM32U5xx Based Boards
Description
The FDCAN Write block writes messages to the Controller Area Network (CAN) network connected to the hardware.
The FDCAN Write block accepts a CAN data that needs to be sent when
operation mode is set to Data. The block accepts a 1-D array of type
uint8 when data format is set to Raw data.
The block accepts input as Simulink® bus signal when data format is set to CAN Message. To extract
data from Simulink bus signal, connect it to FDCAN pack block.
Select the Operation mode and its properties using the block parameters dialog box. Configure the properties of FDCAN module in the configuration parameters.
Examples
Send and Receive CAN or FDCAN Messages on a STM32 processor
Exchange data between STM32 processor based boards using CAN or FDCAN communication.
Ports
Input
The block accepts messages in Raw data format. To accept the
message as a uint8 vector array, set Data Format to Raw
data.
Dependencies
To enable this port, set the Data format to
Raw data.
Data Types: uint8
The block accepts messages in CAN Message format.
You can create your messages or you can upload a CAN database file to FDCAN Pack block.
Dependencies
To enable this port, set the Data format to
CAN Message.
Data Types: CAN Message
The port accepts the length of the received CAN message in bytes.
Dependencies
To enable this parameter, set Data format to
Raw data and Data length via to
Inport.
Data Types: uint8
The port accepts FDCAN message identifier. The ID can be:
0-2047: for Standard (11-bit identifier)0-536870911: for Extended (29-bit identifier)
Dependencies
To enable this parameter, set Data format to
Raw data and Identifier via to
Inport.
Data Types: uint32
The port accepts CAN message identifier type
0- if its 11-bit standard identifier1 or any value other than 0- if its 29-bit standard identifier
Dependencies
To enable this parameter, set Data format to
Raw data and Identifier type via to
Inport.
Data Types: uint8
The port accepts a logical value to put the FDCAN peripheral in sleep mode.
Dependencies
To enable this port, set Operation mode to
sleep.
Data Types: uint8
The port accepts a logical value to put the FDCAN peripheral in wakeup mode.
Dependencies
To enable this port, set Operation mode to
wakeup.
Data Types: uint8
The port accepts a logical value to put the FDCAN peripheral in restricted mode.
Dependencies
To enable this port, set Operation mode to
Exit restricted operation mode.
Data Types: uint8
Output
The port outputs message read status.
The status is
0, if the block reads new message.The status is
1, if the block reads no new message.
Dependencies
To enable this port, select Output Status parameter.
Data Types: uint8
The port outputs the received FIFO fill level.
Dependencies
To enable this parameter, select Output transmit FIFO level parameter.
Parameters
Module to which the FDCAN device is connected.
Programmatic Use
Block Parameter:
FDCANModule |
Select the FDCAN read operation mode.
Data- Data to write FDCAN data/messageSleep- Select to set the FDCAN module in sleep mode. In Sleep operation mode, the block accepts a logical value to put the FDCAN peripheral in sleep mode. When you set operation mode to sleep, it enables the input portSleep.Wakeup- Select to wakeup the FDCAN module from sleep mode. In Wakeup operation mode, the block accepts a logical value to gets the FDCAN peripheral in wakeup state. When you set operation mode to wakeup, it enables the input portWakeup.Exit restricted operation mode- Select to exit the FDCAN module from restricted mode. In Exit restricted operation mode, the block accepts a logical value to exit the FDCAN peripheral from restricted operation mode. When you set operation mode to exit restricted operation mode, it enables the input portRestricted Mode.
Programmatic Use
Block Parameter:
OperationWriteMode |
Select an output type to write message.
RAW data– To write message as a 8-by-1uint8array, select Data format asRaw data.CAN Message– To write message in CAN Message format, select Data format asCAN Message.
Programmatic Use
Block Parameter:
DataFormatWriteMode |
Select an output type to write message.
RAW data– To write message as a 8-by-1uint8array, select Data format asRaw data.CAN Message– To write message in CAN Message format, select Data format asCAN Message.
Programmatic Use
Block Parameter:
CANFrameType |
Select the Identifier Type via Dialog or input
port.
When you select Identifier Type via
inport, the block configures an input port,Id Type.When you select Identifier Type via
Dialog, the block accepts CAN message.
Dependencies
To enable this parameter, set the Data format as Raw
data.
Programmatic Use
Block Parameter:
IdentifierTypeVia |
The type of message identifier.
Dependencies
To enable this parameter, set the Identifier type via as
Dialog.
Programmatic Use
Block Parameter:
IdentifierType |
The type of message identifier.
0-2047: for Standard (11-bit identifier)0-536870911: for Extended (29-bit identifier)
Dependencies
To enable this parameter, set the Data format as Raw
data.
Programmatic Use
Block Parameter:
IdentifierVia |
Identifier, which is 11 bits long for the standard frame size or 29 bits long for the extended frame size, specified in decimal, binary, or hex. For binary and hex formats, use bin2dec(' ') and hex2dec(' '), respectively, to convert the entry. The identifier is coded into a message that is sent to the CAN bus.
Dependencies
To enable this parameter, set the Data Format as
Raw data. To output the identifier of the CAN
Msg, select Output identifier of the CAN
Unpack block.
Programmatic Use
Block Parameter:
Identifier |
Select the Data length via Inport or Dialog.
When you select Data length via
inport, the block configures an input port,Length.When you select Data length via
Dialog, the block accepts specified input data size.
Dependencies
To enable this parameter, set the Data format as Raw
data.
Programmatic Use
Block Parameter:
DataLengthVia |
The length of the message, in bytes provided via input.
Dependencies
To enable this parameter, set the Data length via as
Dialog.
Programmatic Use
Block Parameter:
DataLength |
Select this parameter to enable bitrate switching.
Dependencies
To enable this parameter, set the Data Format as
Raw data, Operation mode as
Data and Frame format as
CAN-FD.
Programmatic Use
Block Parameter:
IsBitRateSwitchingEnabled |
The block sends a remote frame in the CAN message if this parameter is selected. The data at the input port is not sent in the CAN message.
Dependencies
To enable this parameter, set the Data Format as
Raw data and Frame format as
CAN. For CAN Msg, the Remote Frame is inherited from the request
specified in the CAN Pack block.
Programmatic Use
Block Parameter:
TransmitRemoteFrame |
When you select the Output transmit FIFO fill level parameter, the block configures an output port, FIFO level. The port outputs the received FIFO message level.
Programmatic Use
Block Parameter:
OutputTxFifoLevel |
When you select the Output Status parameter, the block configures an output port, Status. The port outputs the status message.
Programmatic Use
Block Parameter:
OutputStatus |
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.
Programmatic Use
Block Parameter:
SampleTime |
Specify the time in seconds to block the CAN read. For nonblocking, set to
0. You configure Timeout to be the maximum time (in seconds) to
wait to complete a read operation.
Programmatic Use
Block Parameter:
Timeout |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

