Dave Turner wrote: > Firstly, I'm not running off battery power. After much fiddling with > config bits I have discovered that with the PIC running on XT mode, it > runs a lot faster than it should if it is using the 32.768KHz clock. > Also, on INTRC mode it runs too fast. On EXTRC, LP or HS mode it > doesn't run at all. Sounds like general confusion about the system oscillator. Get this figured out first, because everything else mostly depends on it. If you're not running on battery power, why not run the PIC at its maximum clock speed of 20MHz? All you need is a 20MHz crystal specified for parallel operation and two caps around 22pF, with the oscillator set to HS mode. If the issues is pins or board space, then the internal oscillator is a good choice. You can use it to run the PIC, and the timer 1 oscillator for accurate timing. > The reason I'm trying to use the 32.768KHz clock as the system clock > is that I don't have a clue how to make a delay by checking a clock - > The only method I know is many embedded loops. Fix this first. Since you're willing to have a crystal anyway, I would make is a 20MHz crystal on the main oscillator. Once you've done that, it's very easy to set up a periodic interrupt of 1mS, for example, using timer 2 and its period register. This would happen once every 5000 instructions, so doesn't add much load to the processor. As long as 1mS is close enough timing for everything else in the system, this will work fine. Once you've got that, there are many ways to implement timers for longer periods. One way is to have a counter for each delay event you need. To wait, you set the counter to the number of mS to wait. The interrupt routine decrements the counter whenever it's not zero, and sets a flag when it decrements it from 1 to 0. Now the foreground code can go off and do other things, and the flag becomes just another event to handle in the main event loop. That's only one of many ways to do this. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist