cancel
Showing results for 
Search instead for 
Did you mean: 

Why is model running faster than real-time?

Jorik Caljouw
Associate
Posted on July 07, 2017 at 17:39

Hi,

I've been trying to use STM32-MAT with MATLAB with an stm32f4-discovery board. I've been having some issues and wanted to post on that for other people. Also I have a problem, I'm not sure how to fix.

I use following versions:

MATLAB, Simulink & Coders R2017a

STM32MatTarget 4.4.1 (with patch from 

https://community.st.com/message/160815-re-many-problems-with-stm32-mat?commentID=160815&sharpcomment-160815

)

STM32CubeMX-4.21.0

SW4STM32 (SystemWorkbench) Not sure which version this is, I installed latest. It shows 2.1.0.201707031232 in About Eclipse for Ac6 C/C+ Embedded Development Tools for MCU

I tried to build the stm32_external_mode model from STM32demos\ExternalMode\NoIoc

However after building, the project opens and a bunch of Include folders are incorrectly pointing to a MATLAB install dir in:

C:\MATLAB\STM32-MAT\Program Files\MATLAB\R2017a

When editing the Projects C/C++ Build > Settings > MCU GCC Compiler > Includes

I can fix it, but it is inconvenient to have to do this manually each and every time a new Project is generated. There it shows:

'../../'../../../../../../../Program Files/MATLAB/R2017a/extern/include''

instead of:

'C:/Program Files/MATLAB/R2017a/extern/include'

Notice the relative path and the 2 sets of double quotes? It seems the .cproject file is not generated correctly and I wonder if I can change this myself.

I am currently postprocessing the .cproject file and replacing:

../../"../../../../../../../

with

C:/

and

""'

with

"'

Now I can build the project and run it on the target and connect from Simulink with External Mode. However the model runs way too fast! 600 seconds in the Simulink model are only taking about 55s in real-time, so it is about 11x real-time.

Any idea why this is? I have attached my .ioc and .slx

Maybe something wrong with HSI vs System Clock? HSI is 16MHz, SYSCLK 168MHz. If the HSI frequency is used instead of SYSCLK for calculating when the step function needs to be called, then I would indeed expect a 168/16=10.5x speedup.

#stm32f4-discovery #stm32mattarget
0 REPLIES 0