I have to generate a random number by taking the input as a timer value... SO can anyone suggest how to get this????
Thanks in Advance
Best is if srand() can be called after the program have been able to pick up some non-constant information that is different each boot.
Not so good is to use the time from the RTC (which, in case the RTC is battery-operated, would differ between each boot) since it is predictable. But since rand() itself can't produce cryptographic-strength random values, RTC data might be good enough.
Better is if there is something that will vary each boot and also can't be predicted. The problem with timers is that they run with a fixed frequency, so they are predictable. To get good use of a timer, it must run with a very high frequency and the time when it is sampled must be unpredictable. A program that always runs the same instructions between the initialization of the timer and the read-out of a timer value, will get the same values - or possibly a very small number of possible values because the CPU core may perform an asynchronous read of the timer.
An ADC might produce a _small_ amount of noise on the read data, that could, after enough reads produce enough random bits. Any interaction with a human being would produce random bits from the varying delays the human introduces between every interaction.
A "good" random source would have been the capturing of thermal noise, which would not only have given a good source of data to use for an initial call to srand(), but would allow the srand()/rand() functions to be completely ignored completely. After all, rand() just creates a limited-length series of pseudo-random numbers, where srand() controlls the start position of this series.
No reply? I'll take that as a "no", then?
www.keil.com/.../search.asp
www.google.com/search