Quickly master STM32 project creation

STM32 project creation--using Keil uVision5 software
Xiaoli Zi

1 Prepare library function library

STM32F10x_StdPeriph_Lib_V3.5.0
VX Search "Xiao Li Zi" to follow and reply STM32F10x to download

2. Create a directory to store the project

STM32Study

STM32Study/study1 stores the directory of this project

3. Open Keil uVision5 to create a project

Insert image description here

4. Select the model (select according to the board model)

Insert image description here

5. Add necessary files to the project

5.1. Startup file

The startup file is located in the library function
STM32F10x_StdPeriph_Lib_V3.5.0\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm

Create a file directory Start in the project file directory and import the files in the startup file into the project file.

Insert image description here

5.2 Copy peripheral register description files and clock files

位于STM32F10x_StdPeriph_Lib_V3.5.0\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x

Also copied into Start

Insert image description here

5.3 Copy memory register file

位于 STM32F10x_StdPeriph_Lib_V3.5.0\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport

Insert image description here

5.4 Load necessary files into the project

Insert image description here

Insert image description here
Insert image description here

6. Add header file path

Insert image description here

Insert image description here

7. Test project availability

7.1 Create the User storage main file in the project

Create a group and rename it User

Insert image description here

7.2 Add main file

Insert image description here

Insert image description here

8. Write test code

#include "stm32f10x.h"                  // Device header

int main(void)
{
	while(1)
	{
	}
}

9. Error handling

9.1 Error 1

Build target 'Target 1'
Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported
  uint32_t result=0;

Reason: The compiled version used is too new

Insert image description here

9.2 Error 2

.\Objects\study2_1.sct(7): error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.

Reason: All startup files have been loaded.

Insert image description here

When the reality is as shown in the figure, the project can be used

Insert image description here

10 debug, burning and debugging

10.1 Select descent mode and set download reset execution

Insert image description here
Insert image description here

11. Programming using library functions

11.1 Copy library functions

Create the Library directory and copy the files in src and inc in \STM32F10x_StdPeriph_Lib_V3.5.0\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\STM32F10x_StdPeriph_Driver

11.2 Add the Library group as above

11.3 Add library function header files containing related files and interrupt functions

Located in STM32F10x_StdPeriph_Lib_V3.5.0\STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template copied to the User file directory

Insert image description here

11.4 Add the header file as above

11.5 Add macro definition

Insert image description here

Insert image description here

12. Compile, download to the board and run

Insert image description here

Guess you like

Origin blog.csdn.net/u011573853/article/details/132656360