Creating a New Project for STM32 in Keil IDE

This is the Series of tutorials on STM32 Microcontroller. The aim of this series is to provide easy and practical examples that anyone can understand. In this tutorial, we will see how to create a new project for STM32 in Keil IDE.

You can also read, STM32 GPIO tutorial, Getting started with STM32 RTOS, LPC2148 Keil IDE installation, 8051 project creation, and 8051 Keil installation.

Installation of Keil IDE

The very first thing is, we need to install the Keil IDE MDK 5.25 or later. MDK 5 uses Software Packs to distribute processor-specific software, examples, and middleware. MDK 5 is installed and the Packs you need are downloaded from the web. They can also be imported manually. You can create your own Packs.

  1. You can download the MDK5 at or
  2. Install MDK into the default folder. You can install it into any folder, but this tutorial uses the default C:\Keil_v5

µVision Software Packs Download and Install

  1. Open the Pack Installer by clicking on its icon: refer to the below image.
  2. A Pack Installer Welcome screen will open. Read and close it.: refer to the below image.
  3. In our STM32 tutorials, we are going to use STM32F401VE. So, select the Devices tab, Select STM32F4 Series as shown below: This will filter the Packs list.  Install the  Keil:STM32F4xx_DFP.  As I have already installed it,  it shows as  Up to date instead of install.

As of now, we have installed the required software. Now let’s create the new project for STM32.

Creating a New project for STM32

  1. Click on the Project/New µVision Project. Refer to the below image.
  2. Create a new folder and provide the desired project name and click the save button in the window as shown below image. I called it the first_project. You can name anything.
  3. As soon as you click on Save, the next window opens. There you need to select your device which is STM32F401VE.
  4. Expand STMicroelectronics, then STM32F4 Series, then STM32F401, then STM32F401VE, and then finally select STM32F401VETx as shown here:  Then Click OK.New project for STM32
  5. The Manage Run-Time Environment window shown below opens.
  6. Select STM32F4-Discovery as the BSP as shown below.
  7. Expand CMSIS and select Core. Expand Device and select Startup as shown below.New project for STM32
  8. They will be highlighted in Green indicating there are no other files needed. Click OK as shown below.
  9. You now have a new project list as shown below: The appropriate CMSIS files you selected have been automatically entered and configured.New project for STM32
  10. You have created a blank µVision project using MDK 5 Software Packs. All we need to do now is add our own source files.
  11. Right-click on Source Group 1 in the Project window and select Add New Item to Group ‘Source Group 1’.Refer to the below image.
  12. Highlight the upper-left icon: C file (.c). And enter your source file’s name. I called it as main.c. Please refer to the below image.New project for STM32
  13. Click on Add to close this window.
  14. Now click on the “Options for Target” button as shown below:
  15. Click the Output tab and select “Create HEX file” as the below image. Then click OK.New project for STM32
  16. Now we have added the new file to our project. We can save our project by Clicking on File/Save All. You can add your source to that file. Like this, you can add as many files as you want.

This is pretty straightforward. In our next tutorial, we will see the GPIO of STM32 with an example.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
Bootloader Tutorials
5 1 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x