Interrupts on these are easier than older 16F parts with the auto restore feature, but you need to make sure you're flipping the right bits to set everything up properly....
Try this.
Then check out DT_INTS-14 v1.00Code:ASM __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _STVREN_OFF ENDASM DEFINE OSC 8 DEFINE INTHAND Tmr1Int OSCCON= %01110000 GOTO Init ' jump over interrupt routine ASM Tmr1Int ; retfie auto-restores w, status, bsr, fsr and pclath bcf T1CON,TMR1ON ; stop timer 1 bcf PIR1,TMR1IF ; clear over flow flag movlw 0xBF ; load timer for 16,535 * 8 prescaler interrupt on 16 bit timer movwf TMR1H ; load high byte movlw 0x69 movwf TMR1L ; load low byte bsf T1CON,TMR1ON ; re-enable timer 1 movlw 0x01 xorwf PORTB,f ; toggle RB0 retfie ; Return from interrupt ENDASM Init: PORTB = 0 TRISB = 0 CM1CON0.7=0 CM2CON0.7=0 ANSELA = 0 ' all digital. A/D disabled ANSELB = 0 PIR1 = 0 ' clear TMR1 int flag PIE1 = %00000001 ' TMR1 int enabled INTCON = %11000000 ' global & peripheral ints enabled T1CON = %00110001 ' TMR1 1:8 prescale, timer1 on Main: HIGH 1 PAUSE 1000 LOW 1 PAUSE 1000 GOTO Main END





Bookmarks