CPU = 16F876 MHZ = 10 CONFIG 16254 ;*********************************************** ; http://www.basicmicro.com ; Title : interrupt.bas ; Author : Dale Kubin ; Date : 04/29/02 ; Interrupts / 32 bit floating point math commands. ; Uses the interrupts with 32 bit floating point ; math to create a real time clock. ;*********************************************** second var byte minute var byte hour var byte tick var byte ftick var long second = 0 minute = 36 hour = 11 tick = 0 ftick = 0 tickcnt con float 1.0038677 oninterrupt tmr1int,clock settmr1 tmr1int4 lcdwrite B4\B5,portb.nib0, [INITLCD1,INITLCD2,CLEAR,HOME,SCR] enable tmr1int main goto main Disable clock ftick = ftick fadd tickcnt if (int ftick) > 19 then ftick = ftick fsub float 19 second = second + 1 if second > 59 then second = 0 minute = minute + 1 if minute > 59 then minute = 0 hour = hour + 1 if hour > 23 then hour = 0 endif endif endif lcdwrite B4\B5,portb.nib0,[SCRRAM] if hour < 10 then lcdwrite B4\B5,portb.nib0,[" "] endif lcdwrite B4\B5,portb.nib0,[dec hour,":"] if minute < 10 then lcdwrite B4\B5,portb.nib0,["0"] endif lcdwrite B4\B5,portb.nib0,[dec minute,":"] if second < 10 then lcdwrite B4\B5,portb.nib0,["0"] endif lcdwrite B4\B5,portb.nib0,[dec second] endif resume