Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/13/05 06:55
Read: times


 
#89561 - Random Number
Responding to: ???'s previous message
One way to obtain a pseudo random number in an 8051 type environment is to start up one of the timers. Lets say you need a value between 0 and 99. Setup one of timers in auto reload mode to repeat itself every 100 counts (do not forget to account for the fact that the timer counts up and ends at 255). The timer can be read to find some pseudo random value. Just take the timer value and subtract it from 255 to get the number you want between 0 and 99.

You pick the time to read the timer based upon some event that is not deterministic such as waiting for the user to press a switch.

Michael Karas

PS....I am mildly amused that you ventured to even guess that this web site would try to hide some secret 8051 opcodes from you. The sum total of the opcodes are shown here on this web page: Opcode Chart
MJK

List of 21 messages in thread
TopicAuthorDate
Randomization?            01/01/70 00:00      
   No RND op code in 8051/52            01/01/70 00:00      
   Random Number            01/01/70 00:00      
   random stuff            01/01/70 00:00      
      We can also count....            01/01/70 00:00      
      But Good Enough!!!            01/01/70 00:00      
      LC RNG            01/01/70 00:00      
      Random what?            01/01/70 00:00      
   maxim's lfsr            01/01/70 00:00      
   the dangers of thinking random is random            01/01/70 00:00      
   wibbly maths            01/01/70 00:00      
      Good old Galois Fields            01/01/70 00:00      
         Bet you didnt know            01/01/70 00:00      
            Try this link            01/01/70 00:00      
               While browsing            01/01/70 00:00      
   rand()            01/01/70 00:00      
      still pseudo            01/01/70 00:00      
         better pseudo!            01/01/70 00:00      
            rand() is part of stdlib.h            01/01/70 00:00      
               true, but not the point            01/01/70 00:00      
                  application dependent            01/01/70 00:00      

Back to Subject List