'Demonstrate TMR0 on IRQ func main() global seconds seconds = 0 pause 1000 print "Start Program" '------------------ 'Initial setup '------------------ INTCON.bit(2)=0 'clear timer0 overflow flag T0CON.bit(7)=0 'Make sure its off TMR0H=103 '1 second (you must always write high byte first TMR0L=150 T0CON.bit(6)=0 '16 bit mode T0CON.bit(5)=0 'Internal clock T0CON.bit(3)=0 'Assign prescale T0CON.bit(2)=1 'Prescale Each Tic = 25.6us T0CON.bit(1)=1 'Prescale T0CON.bit(0)=1 'Prescale T0CON.bit(7)=1 'Start Timer INTCON.bit(5)=1 'Turn on Timer0 IRQ INTCON.bit(7)=1 'Enable Global IRQ's onirq TMR0,letscount loop: pause 100 print "."; goto loop endfunc irqfunc letscount() TMR0H=103 '1 second (you must always write high byte first TMR0L=150 seconds = seconds + 1 print seconds," Seconds" exitirq TMR0 endirq