Home > Software design >  How to initialize random without time
How to initialize random without time

Time:10-03

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

CodePudding user response:

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.

  • Related