> > 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. I hope it is true, I'm not firing on all cylinders today (watched the ODI cricket until 3am), but no one's jumped in to disagree I don't understand how you've got your flash rate either, unless it's by some quirky accident of timing > This same delay routine is working flawlessly in other applications. Hmmm > 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. Unless someone says my calcs are wrong, I don't know how to explain that > I am geting a CORRECT flash rate of approximately 1 Hz on > GP5, and I am simply trying to count 6 cycles of that. Or 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. What I was saying is that you needn't have 3 routines nested 3-deep. You could do it with two (or even just one if you were using a micro that had an interrupting timer). It's just a question of taking the number of cycles in the delay you want and finding factors for it (then smoothing over the cracks if you want very accurate repeatability) > 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? There is a special use for WDT that you may be able to use. You put the micro to SLEEP. When the WDT times out, program flow continues after the SLEEP instruction, rather than a reset It's quite simple to do, and is well-documented with no gotchas that I recall -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads