DEFINE INTHAND ROLLOVER wsave var BYTE $020 SYSTEM wsave1 var BYTE $0a0 SYSTEM wsave2 var BYTE $120 SYSTEM wsave3 var BYTE $1a0 SYSTEM ssave var BYTE BANK0 SYSTEM psave var BYTE BANK0 SYSTEM i_hour var BYTE i_minu var BYTE i_sec var BYTE i_tic var BYTE i_tic_temp1 var BYTE i_tic_temp2 var BYTE i_bits var BYTE 'UNREMARK if you want to use i_100ms_flag var i_bits.0 'UNREMARK if you want to use GOTO AFTERINT 'Jump past interrupthandler asm rollover ;***************************************************************************************** ;***************************************************************************************** ; ; If you are using a PIC with 2K or less, ; you MUST unremarke the lines that follow. ; ; movwf wsave ;only for PICs with 2k or less ; swapf STATUS,w ;only for PICs with 2k or less ; clrf STATUS ;only for PICs with 2k or less ; movwf ssave ;only for PICs with 2k or less ; movf PCLATH,w ;only for PICs with 2k or less ; movwf psave ;only for PICs with 2k or less ; ;***************************************************************************************** ;***************************************************************************************** ; interrupcode follows here movlw 0x16 ;restart timer from (256 + 12 + 4) - 250 => 4000 Hz (could need adjustment) movwf TMR0 decfsz _i_tic_temp1,f goto slutint movlw 40 ;40 = 100Hz if using 4MHz movwf _i_tic_temp1 decfsz _i_tic_temp2,f goto slutint movlw 10 ;10 = 10Hz if using 4MHz movwf _i_tic_temp2 bsf _i_bits,0 ;sets bit0 of reg i_bits each 100ms decfsz _i_tic,f goto slutint incf _i_sec,f movlw 10 ;10 = 1Hz if using 4MHz (change to 20 for 8MHz and so on) movwf _i_tic movf _i_sec,w sublw 60 btfss STATUS,Z ;check for 60 sec goto slutint ;no clrf _i_sec ;yes incf _i_minu,f movf _i_minu,w sublw 60 btfss STATUS,Z ;check for 60 minutes goto slutint ;no clrf _i_minu ;yes incf _i_hour movf _i_hour,w sublw 24 btfss STATUS,Z ;check for 24 hours goto slutint ;no clrf _i_hour ;yes slutint bcf INTCON,2 ;zero tmr0 interrupt flag ;end of interruptcode ; restorecode follows here movf psave,w ;restore movwf PCLATH swapf ssave,w movwf STATUS swapf wsave,f swapf wsave,w retfie endasm AFTERINT: INTCON = %00100000 'all interrupts off, enable tmr0int OPTION_REG = %11011111 'reset bit4 = internal clock to timer0 TMR0 = 250 i_hour = 0 i_minu = 0 i_sec = 0 i_tic = 10 'this value should be the same as the value of line 20 in the ISR i_tic_temp2 = 10 'this value should be the same as the value of line 14 in the ISR i_tic_temp1 = 40 'this value should be the same as the value of line 8 in the ISR INTCON = %10100000 'interrupts on