Baremetal programming of the STM32f303 from ST Microelectronics


ST Microelectronics recently (late 2015) released a Nucleo board in the form of an Arduino Nano containing an STM32F303 microcontroller. This makes for a great little development environment:
It has a ARM Cortex M4F core
It has plenty of RAM and ROM
It has lots of timers
It has an ADC
It has a DAC
It can be plugged into a breadboard.

The board is mbed enabled which means that it behaves like a mass storage device when attached to your computer. You can download the output of the mbed compiler to it simply by dragging and dropping the executable onto the "disk" that it emulates. This site however takes a different approach and uses the built-in STLink-V2 debug interface to program and debug the device.
The eventual aim is to do some DSP using CMSIS DSP libraries and the built in DAC/ADC.
All work was carried out on Fedora 23 starting in early 2016. Openocd (version 0.11 snapshot) was used to connect the board to the ARM GNU debugger (arm-none-eabi-gdb). GCC and GDB cross compilers for ARM were obtained from
openocd was launched as follows:
sudo /usr/local/bin/openocd -f /usr/local/share/openocd/scripts/board/st_nucleo_f3.cfg
Note the board type is not quite the same as the Nucleo '303 but they are both Cortex M4's and both include the same debug interface so this works out fine.
As usual with this site, all programming examples are written to be as simple as possible and be completely self contained in a single directory.

Sample Code

Serial communications. This program uses the built-in serial interface in the nucleo board to communicate with a host PC. The serial interface connects to USART2 on the STM32F303 MCU.
Serial ADC. This program relays the ADC output to the serial interface so you can observe it on the host pc
Analog passthrough. This program passes the ADC output to the DAC with sample rates up to about 100kHz.
Implementing an FIR filter using the ARM CMSIS DSP functions and GCC

Back to my ARM project page