on 2/2/02 11:41 AM, Jinx at joecolquitt@CLEAR.NET.NZ wrote: Hi Joe, > Are you using WDT ? You could lose the CLRWDTs otherwise Yes. Am using the WDT. > My quick back-of-envelope calcs suggest the DELAY500 > routine is taking almost 8,000,000 cycles. To be done in 500ms > that would imply a 64MHz crystal (64,000,000/4/2) > (Ignoring 2-cycle DECFSZ) > > (4 x 9) x (4 x 169) x (4 x 81) = 7,884,864 > > At 4Mhz (1us instruction time) this would take 8 seconds Then you will understand my frustration. If what you have calculated is true, then it does not explain my (almost) perfect Flash rate of 1Hz on GP5 (Pin7) which is achieved by two delay calls. This same delay routine is working flawlessly in other applications. I simply can not see how there can be anything wrong with an already proven delay routine and one that seems to be working in this application. I am geting a CORRECT flash rate of approximately 1 Hz on GP5, and I am simply trying to count 6 cycles of that. > Assuming I'm right (lot on today, I feel like an octopus > playing the drums), and your 500ms isn't critical, use > a WDT interrupt for timing (would take about 28 at 18ms > each), or just a two-level nest. Get the internal loop to > around 2000 cycles with NOPs and a 0-255 count for the > external, if you're running at 4MHz. If you want exactly > 500ms you'll have to get the calculator out and take a > look at the timing routine suggestions at www.piclist.com Sorry. A bit much in the above for a newbie. But I like the suggestion of using a WDT for timing. How would one do this? Isn't a WDT interrupt just like a reset with the exception of a couple of flags? Regards, Sean -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads