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#comment-160815)
SW4STM32 (SystemWorkbench) Not sure which version this is, I installed latest. It shows 22.214.171.124707031232 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:
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:
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:
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.