Hi Jerry ,
It is not possible to create a single, universal Simulink block that works across all microcontrollers (like STM32, PIC32, and Arduino) for hardware-specific features such as CAN transmission, because each hardware platform requires its own support package with unique driver blocks. However, you can achieve a level of portability by using abstraction techniques:
- Create wrapper subsystems : for each hardware, each containing the appropriate microcontroller-specific block.
- Use Simulink Variant Subsystems: to switch between hardware-specific implementations based on the target platform.
- Employ custom S-Functions or MATLAB System blocks: though this requires you to manage hardware drivers and code generation for each platform.
While this approach does not create a truly universal block, it allows you to keep your main model hardware-independent and only change the variant selection when switching targets, greatly reducing the effort required for multi-platform deployment.
I hope this helps.