> In the PIC, the answer would be to access the WDT oscillator, > since it has its own RC oscillator that is not in sync with > the PIC internal clock. But, it is NOT available, alas. > I think you can have an indirect access to the WDT counting speed. Reset the WDT and enter an infinite loop that increments a register. When you get a WDT reset, take the value (or last bit) from that register. Does this make any sense ? Tal > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Bob Axtell > Sent: Saturday, May 31, 2003 2:28 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: A Q&D random number generator > > > This application is similar to the Z80 free-running register; > we used it as a reasonable seed value. But if you read the > "random number" repeatedly for 16K times, you will clearly > see a repeating, non-random pattern. > > In the PIC, the answer would be to access the WDT oscillator, > since it has its own RC oscillator that is not in sync with > the PIC internal clock. But, it is NOT available, alas. > > But my choice for a Q&D is to feed the TMR1 Input from an > external RC oscillator running at 200Khz or slightly less > (max speed for TMR1). Then simply grab the LS timer which is > incrementing through as fast as it can. > > I like the single section of an 74HC14, with a resistor from > input to output, with a cap on the input to ground. Costs > just pennies, and you have 5 more drivers to use somewhere > else. You now have a degree of randomness because this RC > oscillator varies considerably with VCC, heat, component aging, etc. > > --Bob > > At 04:18 PM 5/31/2003 -0400, you wrote: > >I'm writing a small application which needs a quick and dirty random > >number generator. Since the number desired will be between > 1 and 255, > >inclusive, it seems to me that a nice way to do it would be just to > >start one of the timers going (I'm using the 18F452) and > read the 8-bit > >counter at the time I need the random number. Since it will be > >continually incrementing and overflowing, this would seem to > be pretty > >random. > > > >But it seems so easy (really just one instruction) that > there must be a > >catch. :-) Anyone see any? (I'm using Timer0 for something > else, but > >since the F452 has four timers, that is no problem). > > > >John > > > >-- > >http://www.piclist.com hint: To leave the PICList > >mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -------------------------- > > -- > http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu