STM32F0 Tutorial 1: Preliminary steps

STM32F0 Tutorial 1: Preliminary steps

I have been working with the STM32 microcontroller since 2012 until now and I found that it is a really good choice for both cost and performance. I have learned to use STM32F1 (Cortex M3) mainstream at first and then discovered F0 (Cortex M0) for over a year already. The high-performance, DSP-included STM32F4 is really powerful but actually, I don’t have any application that requires such power for now so I am still happy with the F0 and F1 stream. I found lots of tutorials about STM32F1 and F0 on the Internet and some of them are really in detail. Though, I found it quite challenging for some people as they don’t know how to start and face some problems with the coding part. So from my experience that I will share here in this tutorial series, I hope that you can find it useful and valuable. Most of my tutorials will base on applications using peripherals of the microcontroller so that you can get the basic idea of what it is used for and I will keep it as simple as possible. I am also in the process of learning to use all of its capabilities and my knowledge about it is not perfect at all so if I make some mistakes in this STM32F0 tutorial series, please give me a comment below the post. Besides, these tutorials in this series are not limited to F0 only, other types of STM32 microcontrollers can also be discovered by using the same method and libraries provided here. So let’s get started.


Hardware – STM32F0 Discovery Kit

In this STM32F0 tutorial series, the STM32F0 Discovery board will be used as its price is quite affordable to everyone and it has a built-in ST-Linkv2 for easy program downloading and debugging. You can buy it directly from ST or some distributors and the price is only 9 USD for the whole thing. Compared to some popular 8-bit microcontrollers, the ARM Cortex M0, STM32F051R8 in the STM32F0 Discovery board for specific, has some remarkable features here.

STM32F0 discovery kit schematic can be found here:

Datasheet of this device:


From the datasheet file, you can extract some very useful information such as: How many peripherals this device has, and which function each pin has because 1 pin can have many functions, and peripherals connect to. One more thing that you can learn from the kit schematic is the way they design the power for the chip, and how they arrange the power components around the main chip to reduce noise, …

Integrated Development Environment (IDE), Compiler – Keil ARM

An IDE is software that combines project management, making facilities, source code editing, compiling, program debugging, and complete simulation in one environment. There are several IDEs that can be used to program ARM microcontrollers, such as:

  • Keil uVision
  • IAR
  • TrueSTUDIO
  • CoIDE

However, I recommend using the first 3 options as ST officially made their example projects in this environment. After doing a pole from some experts in this field, I chose to go with Keil uVision because it is the official tool by ARM. In those STM32F0 tutorials, I will use Keil uVision 4.

First, you can download Keil v4 from the official site: This version has a limit of 32KB for compiling ad debugging. It’s quite enough for those who get started with most of the applications.

Editor – Source Insight

Most people including me, who first started using Keil, found it quite difficult to code because the code editor is not so ‘attractive’. All the functions, variables, and defines… are having the same color which will make you confused to trace and follow. Therefore, I recommend you to use one additional software called ‘Source Insight’ to make it easier for us to code and learn to code as it provides a more colorful coding environment.


source insight

You can download Source Insight 30 days trial version 3.5.72 here:

—– Can try >> this << to extend the day 😈 .

Update 1/2/2015:



At first, I planned to make tutorials based on the StdPeriph library. However, ST has just released the new version of STM32CubeMX and its libraries which support all kinds of STM32 microcontrollers including F0, F1, F2, F3, F4, L0 and L1 streams. This kind of software was made to help you create a new STM32 project and set up all configurations in the fastest way compared to the traditional method where you need to create project folders, copy library files,… The newest version is v4.6.0, which you can download from here

Some features about STM32CubeMx:

  1. Easy to configure the peripherals, IO, clock source and clock speed… You will no longer need to code the configuration parts, this software will do it automatically.
  2. You don’t have to worry about updating your library for all the STM32 chips you are using again, the software will do it instead.
  3. Create a folder including all necessary files for your project based on the configurations you have made. It also generates the ready-to-open Keil or IAR project file with all the peripherals, clock setting parts. All you need to do is open the file and start to code the main program.

The next tutorial will be about setting up a new blinking LED project using STM32CubeMx.