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.

STM32F0

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: http://www.st.com/st-web-ui/static/active/en/resource/technical/layouts_and_diagrams/schematic_pack/stm32f0discovery_sch.zip

Datasheet of this device: http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00039193.pdf

F0-pins

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: https://www.keil.com/demo/eval/armv4.htm. 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: 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: http://www.mediafire.com/download/vlha9lvjmb6gmge/Si3572Setup.rar.

—–  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)

ST provided this kind of peripherals library to help us to program easier. You can download it from here: http://www.mediafire.com/download/qhob2i5s34ajolt/STM32F0xx_StdPeriph_Lib_V1.0.0.rar

—————————————————————————————————————————————————

Update 1/2/2015:

5. STM32CubeMx

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.

May ap trung ga, mayaptrung.com, may ap trung

Crckkeilc
Crckkeilc
crckkeilc.zip
931.9 KiB
397 Downloads
Details

9 Thoughts on “STM32F0 Tutorial 1: Preliminary steps

  1. Aroun on 17/05/2015 at 5:55 PM said:

    dear thank you for this work. Very nice!
    I am teacher and some time I have a difficulty on teaching peripheral configuration (lot of options). so ST tools are nice. However, I notice that the generated code can be hard to understand. So a tutorial that explain the code (specially the interrupt management, systick for example) is welcome.
    Also can you give more information on how to have a few additionnal days for source insig. I will use it to prepare my courses . Thanks in advance

  2. Aroun on 17/05/2015 at 8:07 PM said:

    Hi Tan Phuc
    Thank you very much! I see your youtube channel, very nice! thanks again

  3. Aroun on 17/05/2015 at 8:46 PM said:

    I am trying my first STMCubeMx project! Thank for the helps! Will keep you inform!

  4. Aroun on 17/05/2015 at 10:06 PM said:

    Hi Tan Phuc,
    Do you know how to disenable systick interrupt? Thank in advance

  5. Aroun on 17/05/2015 at 10:22 PM said:

    ok I get it : use HAL_SuspendTick(void) to disenable it.
    Very nice functions with __weak mean programer can build his/her own function!

    • Le Tan Phuc on 18/05/2015 at 2:19 PM said:

      Haha, this is great when you can find the answer yourself before I see your question 😀 Actually, with Source Insight, your can trace back to every function, command that help you to understand it.

  6. Karisean on 25/11/2015 at 11:17 PM said:

    Hi. Your article is very useful to me. Can you send a secret number of “kegen.rar” in crckkeilc file. It would be very helpful to me.
    Thank you!

Leave a Reply

Post Navigation