Timer-Matlab-codegenration
- September 20, 2018
- 5 replies
- 3170 views
Dear ST community,
I'm using MATLAB Simulink to implement a BLDC-motor control. Therefore I use the Target Support Package-STM32 Adapter (STM32-MAT/TARGET).
I have problems with the Timer block of this block set.
For a simple test, I designed a control for the built-in LED to blink using the Timer block.
I have done the needed configurations using STM32CubeMX, and Simulink according to the Hands On document (STM32-MAT/TARGET Hands On Rev 2.2).
After building the model and opening the MDK-version 5 from Keil, the generated code is not correctly built.
In the main.c the ‘Infinite loop’ ‘Real time from systickHandler’ is running the function LED_Timer_step(); but this function in LED_Timer.c is empty. (See Figure 1)
So the function LED_Timer_step(void) is doing nothing, and therefore the executed code in the ‘Infinite loop’ is doing nothing and the LED is not blinking.
The LED is just turning on because of the function LED_Timer_initialize(); which runs before the ‘Infinite loop’ . The initialization function is shown in Figure 3.
The main function is shown in figure 2
The Matlab is not generating the code correctly, it should build a code for the function LED_Timer_step().
Another point; according to (STM32-MAT/TARGET Hands On Rev 2.2) three files are generated:
- .mlproject: Generated from MATLAB®. Contains information about .c/.h files to add to project from MATLAB®.
- .mxproject: Generated from STM32 CubeMX. Contains information about .c/.h files generated from STM32 CubeMX.
- .script: Generated from MATLAB®. Contains STM32CubeMX command to generate project.
In my case .mlproject is replaced by .extSettings, see figure 4
Does this have any effect?
P.S. While working on other blocks from Target Support Package-STM32 Adapter (except TIMERS) the simulation works with no errors.
Do you recommend using a certain version of MATLAB?
Why is the code not generating correctly?
Best Regards
Omar Alshishani
