cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Random number For stm32f030

mahmoud boroumand
Associate III
Posted on January 31, 2018 at 09:50

Hello.

dose anybody have any code or library to generate true random number in stm32f030?

1 REPLY 1
henry.dick
Senior II
Posted on January 31, 2018 at 12:15

many possible approaches, two come to my mind:

1) use two clocks to gate each other. at least one of them is an R/C oscillator. this approach relies on the phase noise of an r/c oscillator.

one example on STM32F100 here: 

https://dannyelectronics.wordpress.com/2018/01/14/worlds-simplest-truly-random-number-generator-stm32vl-discovery-kit/

  

it uses the slow 40Khz LSI to gate HSI/HSE. and can be easily ported to your chip: DWT isn't available but SysTick will do as well.

2) use the adc's lsb. you can adc any voltage source, floating, real, or even the temperature sensor / reference. it can be very fast.