crandomsrandpsoc

How to initialize random without time


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


Solution

  • 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.