Is simulink model is independent of microcontrollers?
Show older comments
Is it possible to create a Simulink model that is independent of specific microcontrollers?
For example, in the model, the STM32 block is used for CAN transmission. But if I want to deploy the same model to an Arduino, I have to replace the STM32 block with an Arduino-compatible one.
So, is it possible to create a custom block or abstraction that works across multiple microcontrollers like STM32, PIC32, and Arduino without changing the hardware-specific block each time?

3 Comments
Jerry
on 21 Jul 2025
Moved: Walter Roberson
on 28 Jul 2025
Jerry
on 21 Jul 2025
Moved: Walter Roberson
on 28 Jul 2025
Jerry
on 21 Jul 2025
Moved: Walter Roberson
on 28 Jul 2025
Accepted Answer
More Answers (1)
Nithin
on 28 Jul 2025
0 votes
One approach that you can try is with variant subsystems as mentioned earlier, which should solve your problem. Refer to the documentation for more details: https://in.mathworks.com/help/simulink/slref/variantsubsystem.html
With this, you can keep the FDCAN blocks for multiple targets within the variant subsystem and implement an expression to control which variant is active based on the target hardware selection in the model config set. With this approach, the model remains the same, however you will have to change the config set based on the desired target.
Categories
Find more on Embedded Coder Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
