ES1 PRJ2, PRJV & PRJD: STM32F05x microcontroller

Custom hardware

By Hugo Arends

© 2017 HAN University of Applied Sciences, version 1.0


During the lessons several modules (like USB-USART converter and I2C LCD) have been connected to the STM32F0-Discovery board to make a system. This additional lesson gives an example where the STM32F051R8T6 microcontroller is used on a custom PCB and how it can be programmed using the SWD interface on a STM32F0-Discovery board. STMicroelectronics has an Application Note (AN4080) on how to get started with STM32F0xx hardware development.

PCB design

The PCB is designed using EAGLE. This software is easy to learn and easy to use and the Light Edition is freeware with the following limitations[1]:

To download EAGLE:

The PCB schematic is displayed in below:

This design can be used as a reference. There are just a few components necessary to be able to use the microcontroller. You could even leave out the 8 MHz oscillator (and corresponding capacitors) and use the internal clock capabilities of the STM32F051R8T6 if timing is not critical in your application.

When designing the PCB layout make sure capacitors C1, C3, C4 and C6 are placed as closed as possible to the MCU.

The design features:

The finalised PCB looks like this:


Programming and debugging of the target microcontroller can be done using the SWD interface. The STM32F0-Discovery User Manual UM1525 describes this interface thoroughly in chapter 4.2.

The SWD connection looks like this:

Just make sure to remove the jumpers from CN2 on the STM32F0-Discovery board. The ST-Link/V2, that is embedded on the STM32F0-Discovery board, is then connected through the SWD interface to the custom board. Programming and debugging is now exactly the same as if it was the microcontroller on the STM32F0-Discovery board.

One thing to notice is that the SWD interface does not provide power supply to the target board. There is a VDD pin on the connector, but that is used by the programmer to read the targets power supply.

When not using the USB connector on the custom board, the STM32F0-Discovery board can be used to get power supply from. In this case an additional wire has to be added from 5V on the STM32F0-Discovery to pin 1 of JP2 on the custom board.

Last but not least, when the custom board is powered (for instance via USB), but the STM32F0-Discovery board is not, then the RESET connection (NRST) of the SWD interface is logic 0. In this case the target microcontroller on the custom board cannot boot! So either power the STM32F0-Discovery board or remove the SWD cable.

Software examples

STMicroelectronics has developed firmware drivers for all their boards on top of the Standard Peripheral Driver Library (STDLIB). These are placed in the so called Utilities folder. So, for the STM32F0-Discovery board there is a folder called STM32F0-Discovery in the Utilities folder with board specific drivers.

For the custom board, called ‘ESE-Practice’, we can also make a driver on top of the STDLIB and place it in the Utilities folder. There are two types of additional hardware available on the board:

  1. LED’s and switches using GPIO
  2. FT232RL using USART1

A μVision project structure might look this:

The contents of each folder is:

The examples can be downloaded from here. More lessons? Click here!