STM32 uses simulink programming

first part

  • First you have to download the official STM 32 simulink package STM32-MAT URL link
  • Then unzip it to install, draw up the installation address by yourself, open the installation directory, you will see the startuop.bat file, double-click to run it will automatically open matlabFiles in the directory
  • Click Set Path, then add the folder you installed, and then click SaveInsert picture description here
    Insert picture description here
  • The first part is complete.

the second part

  • Open the cubemx you installed, select your chip model, configure the peripherals you need, I only configured a clock, download and LED here
  • Then configure the name of your project, select the project path, select your MDK, and then check the Code Generator to generate separate .c and .h
  • Finally select save project in File, you will see a blue ioc file in the path folder, which proves success
    Insert picture description here
    Insert picture description here
    Insert picture description here
    Insert picture description here

the third part

  • I suggest that the simulink project file you create and the ioc file are separated by a folder, or they are directly together.
  • If you open the project created by simulink directly, then the directory outside of matlab is probably not the directory of your project, remember to change this to the directory of your project
    Insert picture description here
  • For the rest, refer to the blog of Great God to teach you how to use simulink with STM32CUBEMX
  • If the light does not flash, go to the main function to see if the code of matlab is already in the main function
  • Block diagram error may appear when you generate it. You can change the fixed step size to 0.001 for this error.

Guess you like

Origin blog.csdn.net/qq_39669243/article/details/109386444