The rand() function in the stdlib.h is suppost to generate random numbers. However in C programming the random number is generated from a variable eg time, date,.. Then in Keil, and the controller, how does this rand() function work.. Cause i tried using it, it worked ok.. The problem is everytime the controller is reseted, it generates the same set of random numbers. And if u randomize again, it will just become a patern instead of a random value.. Example: after reset: 3,5,8,1,4,...etc etc.. after the reset button again... 3,5,8,1,4,...etc etc.. Does this mean there is no other way to generate random numbers?
It's generally a good idea to re-seed your PRNG every so many collisions, just to avoid the sort of situation Erik describes. Initial seeds usually involve the MAC address, serial number, and other such information unique per device. Packet arrival times are a common source of accumulated entropy for later seeds for networked devices. User input (keystroke times) can be useful if you have a user that inputs anything. There are schemes for fairly simple hardware devices for generating random bits, involving amplified resistor noise or tunneling in diodes. You don't really need a nuclear research lab. A Web search can lead you to designs for such things.