HAL Library 18- RNG for STM32Fxxx

STM32Fxxx devices (in most cases) have True Random Number Generator (or RNG). This peripheral can provide 32-bits random number. I made a small library, that you can enable and use it very quickly which is compatible with HAL based drivers.

RNG on STM32Fxxx is based on analog circuitry. It makes analog noise and that noise is connected to linear shift register. Analog circuitry is designed from ring oscillators whose outputs are XORed. For RNG circuitry is also separate LFSR clock and is independent from System clock. This allows RNG to be independent from system clock between different STM32Fxxx devices.


Read more about new HAL libraries


  • True random number generator
  • Supports 32-bit numbers


  • HAL
  • TM
    • STM32Fxxx HAL
    • defines.h

Functions and enumerations


Project is 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...