random number generator seed

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

random number generator seed

Post by yushanh »

Hi all,

I've seen many discussions talking about random number and wonder which solution would be the best? The solution I came up with is using halGetCounterValue() as the srand seed, and it looks functioning pretty well. Any suggestions?

By the way, I use STM32L. No hardware RNG.

Thanks,
Shan
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: random number generator seed

Post by Giovanni »

Hi,

An HW counter has problems as a random numbers generator because it is synchronous with the system clock.

You should try to use some counter driven by the internal IRC oscillator, that would work better. I don't know if it is possible to drive some timers using it, you should verify that.

Giovanni
Post Reply