HAL library 3- DELAY for STM32Fxxx

Delay functions are needed in your program, no matter how optimized and fast program you wanna do.

Delay functions

I’ve updated my delay library to support milliseconds and microseconds delays. Milliseconds based delay is done using systick timer which makes interrupts every 1ms generated by HAL library. For microseconds based delay, DWT cycle counter is used to get maximal optimized delay.

DWT unit is for F4 and F7 only, F0 series does not have DWT, because of Cortex-M0.

Software timers

Library supports software timers generation. Software timer has resolution of 1ms and counts down. It can be used to generate events each X milliseconds in your project.


Read more about new HAL libraries


  • Delay for amount of milliseconds
  • Delay for amount of microseconds
  • Software timers with callback support


  • HAL
  • TM
    • STM32Fxxx HAL
    • defines.h

Functions and enumerations

Example 1

Example 2

Example 3

Projects are available on Github, download all libraries below.


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...