Tangwx

Tangwx

博客网站

Create project using STM32F407VET6 with V1.9.0 standard library.

Creating a project using STM32F407VET6 with V1.9.0 standard library#

1. Creating a new project directory#

For a completely new project, you need to create a new empty project directory. Create a new folder and place 5 subfolders inside it, named Core, Hardware, Library, System, and User. Each folder will contain different project files in the future.

image-20230516094603253

2. Downloading the STM32 firmware library#

The STM32 firmware library includes the library functions (c files and h files) corresponding to the STM32 peripherals, as well as the necessary startup files, etc. The firmware library also needs to be downloaded from the official website. Here, I provide a Lanzou download link.

image-20230516094906621

3. Copying the files from the firmware library to the project path#

First, you need to copy the peripheral files from the firmware library to the project path. Copy the src and inc folders under the firmware library path \STM32F4xx_DSP_StdPeriph_Lib_V1.9.0\Libraries\STM32F4xx_StdPeriph_Driver to the project directory Library. The src folder contains the firmware library .c files, and the inc folder contains the corresponding .h files.

image-20230516102142515

Copy the folder \STM32F4xx_DSP_StdPeriph_Lib_V1.9.0\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm from the firmware library to the project directory Core. The file startup_stm32f40_41xxx.s is the startup file.

image-20230516102508965

Copy the following core files from the firmware library \STM32F4xx_DSP_StdPeriph_Lib_V1.9.0\Libraries\CMSIS\Include to the project directory Core.

image-20230516102620026

image-20230516102737816

image-20230516102903516

Now, these files have been copied to the Core directory.

Copy the folder \STM32F4xx_DSP_StdPeriph_Lib_V1.9.0\Project\STM32F4xx_StdPeriph_Templates from the firmware library to the project directory User.

image-20230516103319225

4. Creating a new project in Keil#

Open Keil5 and select Project → New uVision Project from the top menu bar to create a new project. If you have other projects, click on Project → Close Project first.

image-20230516104320898

Save it to the directory of the folder we just created, and name the file STM32F407VEProject.

image-20230516104415707

Select the chip STM32F407VETx.

image-20230516105042136

Click OK, then close the window below.

image-20230516105128016

Click Manage Project Items.

image-20230516105334004

Modify it to the following form.

image-20230516110855572

Add the following files to Core.

image-20230516111104634

Add all files inside the Library/src folder to Library.

image-20230516111120725

Add the following files to User.

image-20230516111139078

Click OK to close the window.

Click on the magic wand to add file paths.

image-20230516110432554

Add the following paths.

image-20230516111219323

Click OK, then add the global macro definition identifier STM32F40_41xxx,USE_STDPERIPH_DRIVER.

image-20230516111512699

Click OK again.

Open main.c and clear the internal data, leaving only the main function.

image-20230516111912616

Then, delete the import of the main.h header file on line 32 and the content of the SysTick_Handler function on line 144 in the stm32f4xx_it.c file under the User group.

image-20230516112029682

image-20230516112043558

Finally, find stm32f4xx_fmc.c in Library, right-click and select Options.

Uncheck include in Target Build in front of stm32f4xx_fmc.c. stm32f4xx_fmc.c is specific to the STM32F42 and STM32F43 series, so we need to remove it from the project (note that it is stm32f4xx_fmc.c, not stm32f4xx_fsmc.c).

image-20230516112357746

After removing FMC and FSMC, you may encounter the following situation during compilation:

image-20230516122752307

After the compilation is complete, we find that there are still errors. Double-click on the error message with the mouse to find the location of the error.

image-20230516123649754

The reason is that it is defined repeatedly, which can be considered as an official bug. You need to comment out the code that causes the error:

image-20230516123602246

Comment out this part and the warning will disappear.

At this point, the project has been created. Here is the link to the project I created.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.