Project creation

The tutorial demonstrates how to create a new STM32F103RCT6 standard library project.

Project directory

Before using MDK-ARM to create a new project, we need to operate the folders under the project: the operation includes creating a new folder and copying the official standard library firmware package file to the specified folder.

Folder framework

Create a new folder according to the following directory:

image-20240722144718505

CMSIS

Note: startup_stm32f10x_hd.s and startup_stm32f10x_md.s cannot be imported into the project directory at the same time, otherwise an error will be reported!

image-20240722155524109

FWLib

image-20240722152410912

USER

新建工程时,会将工程放在该目录下。

BSP

When creating a new project, store the peripheral driver files of the development board

OBJ

When creating a new project, store the compiled files

Configure the project

Create a new project

Double-click to open the Keil uVision5 software on the desktop

image-20240722153340917

New project: Select the newly created USER folder as the project path, and you can define the project file name yourself

image-20240722154024169

image-20240722154226355

Chip selection

Search in the chip search bar: STM32F103RC

image-20240722154416506

image-20240722154835425

Project file management

It is recommended to add according to the project folder framework

②: Modify according to the project name

③: Modify according to the subfolder name

④: Add the .c and .s files in the corresponding folder

Click OK and it will be like the directory on the left of the picture. Users can compare it by themselves!

image-20240722160226079

Project target options

Target

Select the AC5 compiler

image-20240722170754591

Output

Check the option Create HEX File

image-20240722170209086

Select the location to store the compiled files: Template\OBJ

image-20240722171108194

C/C++

Define: add USE_STDPERIPH_DRIVER

image-20240722170330819

Include Paths: Add all folder paths containing .h files in the project

image-20240722170440663

Compile the project

Click rebuild to compile the project:

image-20240722171223845

If "0 Error(s), 0 Warning(s) appears, it means the project template is created successfully!

Template.hex

Template.hex is the file generated after the project is compiled. You can use the serial port burning program to burn this file into the development board and run it!