Showing results for 
Search instead for 
Did you mean: 

Run MATLAB/Simulink directly on STM32L4 - Speed Limitations?

Associate II


i am currently working with MATLAB/Simulink and followed this tutorial:

When I tried to bring the Pulse Generator to its maximum with Digital Write, surprisingly it already stopped at 25kHz. After some research I found out that this is related to the BaseRateSampleTime and can be set in the solver. After I set this to 1e-7 still no faster frequencies than 25kHz are possible.

Has anyone had the same experience or do I still have a configuration error. Or is it because no faster code can be generated from Simulink?



Associate II

Hi Ch,


I had a similar issue using ADC sampling Triggered by HRTIM. It was stuck at 50kHz using HAL (even without Embedded Coder).


I do also work with Embedded Coder Support Package for STM32 (this is based on LL library instead of HAL, so It is supposed to be faster).


If you can not choose the code generation library (not sure if it is allowed in Nucleo Boards Support Package), I would try to set Optimization level with Priority to Maximize Execution Speed:

Hardware Settings >> Code Generation >> Optimization >> Level: Maximum >> Priority: Maximize execution speed