STM32F0 Tutorial 1: Preliminary steps

I have been working with 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) main stream at first and then discovered to 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 tutorial will base on application 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 capability and my knowledge about it is not perfect at all so that 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.


1. Hardware – STM32F0 Discovery Kit

In this STM32F0 tutorial series, 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 fot the whole thing.  Compared to some popular 8-bit microcontroller, 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, which function each pin has because 1 pin can have many function, peripherals connect to. One more thing that you can learn from the kit schematic is the way they design the power for the chip, how they arrange the power components around the main chip to reduce noise, …

2. Integrated Development Environment (IDE), Compiler – Keil ARM

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

  • Keil uVision
  • IAR
  • TrueSTUDIO
  • CoIDE

However, I recommend using the first 3 options as ST officially made their example projects in these 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 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. When you go further with some graphical application, you can buy a license or try using this cr+ck with your own risk: [wpfilebase tag=fileurl id=23 linktext=’K_MDK’ /]

3. 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, 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.

sourceinsight source insight

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

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

4. STM32F0 standard peripherals library *(This library is no longer recommended to use since ST released STM32CubeMX with newer version HAL library. You still can download and try it yourself but I would recommend using HAL library as it is easier to use)

You can download it from here:


Update 1/2/2015:

5. STM32CubeMx


At first, I planed 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 microcontroller including F0, F1, F2, F3, F4, L0 and L1 streams. This kind of software was made to help your create new STM32 project and set up all configurations in the fastest way compared to 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 opening the file and starting to code the main program.

Next tutorial will be about setting up new blinking LED project using STM32CubeMx.