Programming a Digital Clock using FreeRTOS and STM32F411

Blog Post created by tom.abel on Apr 30, 2018

Hardware Setup:

The board used for this project is STM32F411VE Eval Board.

A GPS Module is used which outputs NMEA Sentences over the Tx Line which is received by STM32.

A 7 segment MAX7219 Display module is used to display the extracted time. This module communicates to STM32 via SPI interface. 

USART to USB module that is used to receive a character by another USART on the STM32 board, entered by user via keyboard.


Software Setup:

The IDE used is SW4STM32,

Compiler is ARM-GCC,

Debugger is OpenOCD,

FreeRTOS version used is v9.0.0.

OS used: Ubuntu 16.04


There are three tasks that are created in the beginning before starting the scheduler. Two binary semaphores are created to handle two different interrupt sources.There is a dummy task that toggles the on-board LEDs.


Task 2 is used to handle the DMA interrupt. NMEA sentences are received from GPS module over USART and upon reception of 128 bytes in this case, a DMA interrupt is generated. A semaphore is given from this interrupt which synchronizes with the handler task. In this DMA handler task, the contents of DMA buffer is copied locally and the parsed time is displayed over SPI interface.


Task 3 is used to handle a asynchronous reception of a byte from the user via keyboard. To do this, another USART module is configured. When a character is received, an interrupt is generated and a semaphore is given from this ISR in order to synchronize with the handler task. At the moment, this task, transmits the received character via USART. But this can be used to display date or some other info on the 7 segment display module.


Standard peripheral drivers are used for this project, no MxCube.

The entire source code for the project can be found: Github link --> here.