cancel
Showing results for 
Search instead for 
Did you mean: 

i am using stm32f401re, can i use random number generate function or is there any alternative way

Rmajj.1
Associate II
 
4 REPLIES 4
KnarfB
Principal III

> can i use random number generate function or is there any alternative way

The stm32f401re doesn't have true random generator hardware (RNG or TRNG) on chip which can be used for some crypto algortihms. There is an app note AN4230 Application note telling you more about RNG.

The C-library rand() function is a pure software pseudo-random number generator (PRNG). It will generate the same pseudo-random number sequence after each reset. You can circumvent that by calling seed with some entropy (RTC + 96 bit unique chip ID ...). The actual implementation of rand is not standardized. Its quality may vary as there is a tradeoff between quality and speed. There are better software PRNGs around.

thank you knarfb

but by calling seed.when reset agian we are getting same sequence of random number.

rtc means tick value ???

no. Real-Time-Clock. Thats useful if you want to get a new seed on ervery reset. I'm sure you find a compatible type with TRNG https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32f4-series.html