Are you using WDT ? You could lose the CLRWDTs otherwise > __CONFIG & _WDT_ON & 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 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 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads