- stm32_can_gettingstarted.slx - Internal Loopback for CAN
CAN Communication Between Arduino Due and STM32-Nucleo-F446RE – Data Reception Issue
17 次查看(过去 30 天)
显示 更早的评论
Hello,
I am currently working on CAN communication between an Arduino Due and an STM32-Nucleo-F446RE.
The goal is to send data from the Arduino Due and receive it on the STM32 using Simulink, then forward the received data to the PC via UART for verification.System Configuration:
- Hardware Setup:
- Arduino Due is connected to an SN65HVD230 CAN transceiver module for sending CAN messages.
- STM32-Nucleo-F446RE is also connected to an SN65HVD230 CAN transceiver module for receiving CAN messages.
- Software Configuration:
- On the Arduino Due, I am using the due_can library to send CAN messages.
- On the STM32, I am using Simulink's CAN Read and CAN Unpack blocks to receive the data and forward it via UART to the PC for monitoring.

Current Issue:
The Arduino Due is configured to send the value 1 with CAN ID 0x123, and the Serial Monitor confirms that the message is being sent correctly.
However, on the STM32 side, when receiving the CAN data in Simulink and transmitting it via UART, the output is always 0.
Observed UART output:
📡 Receiving UART data...
📩 STM32 Received Data: 0
📩 STM32 Received Data: 0
📩 STM32 Received Data: 0
📩 STM32 Received Data: 0
Questions:
- Are the current CAN Read and CAN Unpack block settings in Simulink correct?
- I have set CAN ID: 0x123, Length: 1 Byte, and data: 1
- CAN1 in STM32CubeMX is configured for 500 kbps, with GPIO pins PA11 (CAN_RX) and PA12 (CAN_TX).
- Are there any additional settings I need to check?
- How can I verify that Simulink is correctly receiving CAN messages?
- For example, is there a way to debug before forwarding the data to UART, to check if the CAN message is properly received?
If I am missing anything in the setup, I would appreciate your guidance.
Thank you!
1 个评论
Haelee
2025-2-24
To verify CAN configurations, you can check out this document:
The model "stm32_can_gettingstarted.slx" from the document will especially help you try out the internal loopback for CAN.
回答(1 个)
Vikky Patil
2025-3-4
编辑:Vikky Patil
2025-3-5
Attached is an example for the same
Arduino Due is sending decimal values 65 to 90(ASCII A to Z) via CAN0 and Nucleo F446RE CAN1 receives the data and send it over USART2 which can be seen over Putty on Host. CAN0 of Due and CAN1 of STM32 are connected via can-transceivers.

Answering your question
- Are the current CAN Read and CAN Unpack block settings in Simulink correct?I have set CAN ID: 0x123, Length: 1 Byte, and data: 1 : This looks fine
- CAN1 in STM32CubeMX is configured for 500 kbps, with GPIO pins PA11 (CAN_RX) and PA12 (CAN_TX).: The above example is tried on PB8 (CAN1_RX) and PB9 (CAN1_TX). The example shows the confgiration that need to be done, you can try the other supported pins at your end
- How can I verify that Simulink is correctly receiving CAN messages? For example, is there a way to debug before forwarding the data to UART, to check if the CAN message is properly received?: You can debug the Simulink generated code in STM32CubeIDE
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!