How to initialize random without time

146 Views Asked by At

I am programming a microcontroller (PSoC5), which doesn't have a system time.

What is the best way to generate a seed to initialize srand?

TIA

1

There are 1 best solutions below

3
On BEST ANSWER

If the chip has ADCs, one option is to take advantage of noise picked up on the ADCs. Basically, you can take a few reads of the ADCs, then bitwise AND to keep the least significant bit. Then use the all of the least significant bits sampled to generate your seed.