Beginning STM32F04 programming (Part 1: Minimal example)

Today we are launching a new series on programming the STM32F0 – we won’t be using neither the Standard Peripheral Library (SPL) nor the HAL library provided by ST, so this will be as close to the hardware as it could get! While it may seem odd to deal with register fiddling and stuff on our own, it really helps understanding the underlying hardware and gaining a better insight into the peripherals.

The example program below is as minimal as it possibly gets, but helps setting up everything, i.e. the programming environment as well as our debug and flash tool (I use a Nucleo board for this purpose which already provides the ST-Link onboard).

If you have a look at the STM32F04 Nucleo datasheet, you’ll see that LED3 (LD3) is connected to the GPIO PB3 – blinking the LED helps to ensure that our environment is set-up correctly.

If done correctly, you should now see the green LED next to the user button on top of the Nucleo board switching on and off infinitely.