Project Creation In Μvision Ide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

Project Creation in µVision IDE


Yifeng Zhu
January 3, 2016

Summary
This tutorial takes the following the kits as an example of creating a project in Keil IDE for assembly programs.
 Discovery kit with STM32L152RCT6 MCU (Cortex-M3)
 Discovery kit with STM32L476VG MCU (Cortex-M4 with FPU and DSP)
Note that the project does not use the default startup files provided by Keil. You need to download a
modified version of startup_stm32l1xx_md.s or startup_stm32l476xx.s from the book website:
http://web.eece.maine.edu/~zhu/book/lab.php.

Identifying Target Processor


Kit Processor Core Flash RAM
STM32L1 Discovery Kit STM32L152RBT6 Cortex-M3 128 KB 16 KB
STM32L1 Discovery Kit STM32L152RCT6 Cortex-M3 256 KB 32 KB
STM32L4 Discovery Kit STM32L476VG Cortex-M4 (DSP + FPU) 1 MB 128 KB

Steps to create a new project in Keil


1. From the menu Project ⟶ New µVision Project
2. Give the project a name and select its storage directory. In this tutorial, the project is named as “lab”.
3. If you use the STM32L1 Discovery Kit, select the device STM32L1 Series, and then select STM32L152RC
or STM32L152RB as the CPU. If you use the STM32L4 Discovery Kit, select the device STM32L4 Series,
and then select STM32L4476VGTx.

If did not see the targeted processor in the list, click the “Pack Installer” button and install the component
Keil::STM32L1xx_DFP or Keil::STM32L4xx_DFP.

1
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

4. Select CMSIS Core only. Do NOT select “Device Startup”. Instead, you should use the one provided by the
course website.

5. If you are STM32L1 discovery kit, add the following source code files into the project. Right click the
“Source Group” and select “Add Existing Files to Group.” You can download the following source codes
from the textbook website and adds into the project if you are creating an assembly-based project.

 startup_stm32l1xx_md.s
 core_cm3_constant.s
 stm32l1xx_constants.s
 stm32l1xx_tim_constants.s
 main.s

If you use STM32L4 discovery kit, add the following source code files into the assembly-based project.

 core_cm4_constants.s
 stm32l476xx_constants.s
 startup_stm32l476xx.s
 main.s

2
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

If you are creating a C project, then you should include the following:

 startup_stm32l1xx_md.s or startup_stm32l476xx.s
 main.c.

6. Set Project Properties

From the menu, click Project ⟶ Option for Target, Go to the Output page, select “Create HEX file”

3
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

Go to the Linker page, select “Use Memory Layout from Target Dialog”

Go to the Debug page, select “ST-Link Debugger”

Click “Settings” and select “SW” (Serial Wire) as the port.

4
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

Go to the Flash Download page, and verity that STM32L1xx On-chip Flash is selected in the Programming
Algorithm. If not, click “Add” and select STM32L1xx On-chip flash in the popped dialog.

STM32L1 Discovery Kit STM32L4 Discovery Kit

5
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C ISBN 0982692633

7. Compile and run your project


Build the program:

You can ignore the following warning when the linking stage:
.\Objects\lab.sct(8): warning: L6314W: No section matches pattern *(InRoot$$Sections).

Connect your discovery kit to the computer and download the program to the STM32L processor.

You might also like