Or one could suggest that he could get fairly close to exactly 5ms by investing in an atomic clock ;-) ----- From: "Andrew Warren" On 31 Aug 2004 at 8:20, Olin Lathrop wrote: > > > Specifying an analog quantity as "exactly" is useless, and immediately > > tells us that the person doing the speccing doesn't know what he's > > doing. > > Or maybe it just tells us that we're holding that person to an > unreasonably (or, at least, unusually) high standard of precision in > his usage of the language. > > > Since 5mS can't be achieved "exactly", we can only ignore it and take > > our own guess about how close is close enough. > > Right. When someone asks for "exactly five milliseconds", but > doesn't mention anything about the tolerance of his oscillator or > about theoretical physics, MY guess -- and, I expect, yours -- is > that he means "exactly five milliseconds, assuming that my > oscillator is running exactly at its nominal frequency". > > It's like someone asking, "How can I get my PIC to just sit and wait > forever for a pin to go high?" I don't think he wants me to answer > that by explaining how the Second Law of Thermodynamics makes > "forever" impossible; he'd probably prefer that I just draw up a > BTFSS/GOTO loop and remind him to disable the watchdog timer. > > > Given that, what's the best way to teach someone to time 5mS on a PIC? > > This is 1000s of instruction cycles even at a modest clock rate, so I > > think a busy loop shouldn't be the first recommendation. > > How likely is it that he needs to do something else while waiting > those five milliseconds? He didn't SAY that he did... > > If he's just waiting, a busy loop is by far the easiest and most > appropriate solution. > > > > DELAY5K: > > > CALL DELAY1K > > > CALL DELAY1K > > > CALL DELAY1K > > > CALL DELAY1K > > > DELAY1K: > > > MOVLW 249 > > > LOOP: > > > ADDLW -1 > > > SKPZ > > > BRA LOOP > > > RETURN > > > > If you've decided you want a busy loop for whatever reason, this sort > > of structure is reasonable. > > Thanks. > > > However, getting the details just right can be very tricky. Counting > > cycles isn't as easy as it may seem, especially for a beginner. > > True. Good thing the PICLIST is here to help those beginners. > > -Andy > > _______________________________________________ > http://www.piclist.com > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist