- Within your root project folder go to the directory "<projectName>/Src" (these files habe been created by MATLAB, without STM32CubeMX doing anything to them)
- Copy all those files to the default "src" folder of the STM32CubeIDE project.
- Now hit "Run" again and it should compile with no errors.
Simulink code generation for STM32: how to generate the .bin file?
46 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dionisio Cagigas Fojaco
el 13 de Mzo. de 2020
Respondida: Sergio Jiménez Concha
el 7 de Ag. de 2023
Hi everyone,
I have bought a STM32F4-Discovery Board DTM32F429I-Disc1, and my intention is to work in Matlab-Simulink.
This is the process I have followed:
- INSTALLATION: Matlab/Simulink R2018b 64bit with toolboxes like Embedded Coder
- INSTALLATION: Matlab/Simulink HW support package "Embedded Coder Support Package for STMicroelectronics Discovery Boards"
- INSTALLATION: STM32-MAT/TARGET from ST
- INSTALLATION: STM32CubeMX from ST
- INSTALLATION: STM32CubeIDE_1.3.0 from ST
Within STM32CubeMX, generate the .ioc file for the right board/MCU in order to blink the green LED:
- Give it the name "BlinkLED"
- PG13 as GPIO_Output and with a name "GreenLED"
- Select Toolchain\IDE = STM32CubeIDE (Project Manager \ Code Generator)
Within Matlab-Simulink:
- Add the STM32-MAT/TARGET path to Matlab's path (pathtool)
- Create a new simulink model
- Within the configuration parameters:
- Solver: Fixed-step, stop time = inf, step time = 0.001
- Code generation: Select the target file as "stm32.tlc" (This takes a while...)
- Code generation: Within the STM32 options, update the STM32CubeMx path
- Open the Simulink library and at the bottom should be the library for "Target support package - STM32 adapter"
- Select block "STM32_Config" and link to the .ioc file generated within STM32CubeMx
- Select block GPIO_Write and configure the pin 13
- Build (Ctrl+B)
- SUCCESSFUL!
However, I can not find a .bin file that can programmed on the board using the "ST-Link Utility". Any ideas?
Other option is to open the .project generated within STM32CubeIDE, but there are seem to be some files missing?
Thanks a lot
3 comentarios
GUILHERME VIANNA SANTOS
el 12 de Feb. de 2021
Editada: GUILHERME VIANNA SANTOS
el 12 de Feb. de 2021
Hello,
I also found problems to complete the generated code, as reported by @Pascal Weller. The code generated by simulink was produced separately from the codes generated by STM32cubeMx and another by simulink, for example two main files were generated. I used STM32cubeMx version 6.1.1
To solve the problem I revert the version of STM32CubeMx to version 5.6.0. The .c and .h files are generated correctly, but in the STM32CubeIDE interface it is necessary to add to the project the folders generated by the simulink code generator. After that the compilation takes place correctly.
Maybe you already solved the problem, but this solution can help others maybe...
Pascal Weller
el 23 de Feb. de 2021
Editada: Pascal Weller
el 23 de Feb. de 2021
Hello,
Unfortunately, I do not remember which version I used back then. Anyways, thanks for your input on the topic.
Best,
Pascal
Respuestas (2)
Dionisio Cagigas Fojaco
el 31 de Mzo. de 2020
4 comentarios
Muhammad Bilal Aziz
el 28 de Sept. de 2020
Hi Dionisio Cagigas Fojaco, I am using Nucleo F746ZG LQFP144. I followed the same procedure as you mentioned. But the problem is simulink is creating the .c and .h files but they are not generating on my ide.(Keil or stm32cubeide). Please help how to run those files(.c and .h) on the ide.
Thanks alot .
zini giacomo
el 25 de Feb. de 2021
Editada: zini giacomo
el 25 de Feb. de 2021
similar problem here:
my procedure is this
1)Open CubeMX and create a simple project with atollic truestudio as toolchain, then i don't create the project just save the .ioc file in my workspace
2)open matlab, create a folder in the main workspace and in it i create an slx model
3)open simulink, in model configuration parameters:
stop dime=inf
fixed step
sample time= 1e-3
code generation:
system target file= stm32.slc
STM32 options:
tick on stm32cubeMX path
4)stm32_Config block i select the .ioc file
5)make a simple model of a blinking led
6)save
7)apps->Embedded Coder->Custom Target and select again stm32.slc
8)Build
9) at this point i got a project with the main.c exactly as cubeMX had create it with the while(1) empty
10)now i can build and debug but of course the code don't do anything, because the function in the .c file with the simulink progect is never called
EDIT:
i 've solved selecting BASIC from application structure in cubeMX
actyally you need just to select BASIC from application structure, even if you have teh latest version of cubeMX, at leas it worked for me.
Ver también
Categorías
Más información sobre STMicroelectronics Discovery Boards en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!