I've started tinkering with a PIC18F4680 (with CAN bus) using microchips MPLAB C18 C compiler. I've been beating my head against a problem for many hours now :evil: . I can't get interrupts to work. I have tried, TMR0, TMR1 and INT0. I have verified that TMRnIP, TMRnIE, TMRnIF and GIEH & IPEN are all HIGH yet my ISR does not get run. If I clear TMRnIF in the main loop TMRnIF is set again when the timer overflows so it appears the timer is OK, the ISR just doesn't get run. I have checked the disassembly and there is a goto in 0x08 (the high pri interrupt vector) and my ISR at the address GOTOed. Any suggestions what the issue may be? Here is a section of my code : 38: RCONbits.IPEN = 1; //enable priority levels 00003C 8ED0 BSF 0xfd0, 0x7, ACCESS 40: IPR1bits.TMR1IP = 1; 00003E 809F BSF 0xf9f, 0, ACCESS 41: PIR1bits.TMR1IF = 0; 000040 909E BCF 0xf9e, 0, ACCESS 42: PIE1bits.TMR1IE = 1; 000042 809D BSF 0xf9d, 0, ACCESS 43: TMR0H = 0; //clear timer 000044 6AD7 CLRF 0xfd7, ACCESS 44: TMR0L = 0; //clear timer 000046 6AD6 CLRF 0xfd6, ACCESS 46: INTCONbits.GIEH = 1; //enable interrupts 00004C 8EF2 BSF 0xff2, 0x7, ACCESS 47: 48: T1CONbits.TMR1ON = 0; 00004E 90CD BCF 0xfcd, 0, ACCESS 49: TMR1H = 0x00; 000050 6ACF CLRF 0xfcf, ACCESS 50: TMR1L = 0x00; 000052 6ACE CLRF 0xfce, ACCESS 51: T1CONbits.TMR1ON = 1; 000054 80CD BSF 0xfcd, 0, ACCESS << snip >> 67: //---------------------------------------------------------------------------- 68: // High priority interrupt vector 69: 70: #pragma code HIGH_INTERRUPT_VECTOR = 0x08 71: void 72: InterruptVectorHigh (void) 73: { 74: _asm 75: goto InterruptHandlerHigh //jump to interrupt routine 000008 EF3E GOTO 0x7c 00000A F000 NOP 76: _endasm 77: } 00000C 0012 RETURN 0 78: 79: //---------------------------------------------------------------------------- 80: // High priority interrupt routine 81: 82: #pragma code 83: #pragma interrupt InterruptHandlerHigh 84: 85: void 86: InterruptHandlerHigh () 00007C CFDA MOVFF 0xfda, 0xfe4 00007E FFE4 NOP 000080 CFE2 MOVFF 0xfe2, 0xfda 000082 FFDA NOP 000084 52E6 MOVF 0xfe6, F, ACCESS 87: { 88: // INTCONbits.TMR0IF = 0; //clear interrupt flag 89: Flags.Bit.Timeout = 1; //indicate timeout 000086 0100 MOVLB 0 000088 8160 BSF 0x60, 0, BANKED 90: LATAbits.LATA0 = !LATAbits.LATA0; //toggle LED on RB0 00008A 7089 BTG 0xf89, 0, ACCESS 91: // INTCONbits.INT0IF = 0; 92: PIR1bits.TMR1IF = 0; 00008C 909E BCF 0xf9e, 0, ACCESS 93: } 00008E 52E5 MOVF 0xfe5, F, ACCESS 000090 CFE5 MOVFF 0xfe5, 0xfda 000092 FFDA NOP 000094 0011 RETFIE 0x1 Any help will something heavy being thrown against my wall. Thanks. Dean
Interrupt not firing on PIC18F
Started by ●February 23, 2005
Reply by ●February 23, 20052005-02-23
I have just been bitten by a problem that sounds very similar to this. I was using the CCS C compiler with a PIC18LF252 and could not get the interrupts to run. Examining the registers showed everything looked "normal" and the overflow bit (it was a serial interrupt) was being set on the second character sent. After much comparing of files, etc. I found out it was the DEBUG fuse. For some unknown reason, if the DEBUG fuse was set, I got no interrupts. When I cleared the DEBUG fuse, recompiled, and loaded it again, everything worked fine. According to the part datasheet (even errata), the serial interrupt should not have been affected by the DEBUG fuse. Apparently it is. Dave "namezmud" <drtroake@hotmail-dot-com.no-spam.invalid> wrote in message news:bsKdnQMfGuoMpYHfRVn_vA@giganews.com...> I've started tinkering with a PIC18F4680 (with CAN bus) using > microchips MPLAB C18 C compiler. I've been beating my head against a > problem for many hours now :evil: . > > I can't get interrupts to work. I have tried, TMR0, TMR1 and INT0. I > have verified that TMRnIP, TMRnIE, TMRnIF and GIEH & IPEN are all > HIGH yet my ISR does not get run. If I clear TMRnIF in the main loop > TMRnIF is set again when the timer overflows so it appears the timer > is OK, the ISR just doesn't get run. > > I have checked the disassembly and there is a goto in 0x08 (the high > pri interrupt vector) and my ISR at the address GOTOed. > > Any suggestions what the issue may be? > > Here is a section of my code : > > 38: RCONbits.IPEN = 1; //enable priority > levels > 00003C 8ED0 BSF 0xfd0, 0x7, ACCESS > 40: IPR1bits.TMR1IP = 1; > 00003E 809F BSF 0xf9f, 0, ACCESS > 41: PIR1bits.TMR1IF = 0; > 000040 909E BCF 0xf9e, 0, ACCESS > 42: PIE1bits.TMR1IE = 1; > 000042 809D BSF 0xf9d, 0, ACCESS > 43: TMR0H = 0; //clear timer > 000044 6AD7 CLRF 0xfd7, ACCESS > 44: TMR0L = 0; //clear timer > 000046 6AD6 CLRF 0xfd6, ACCESS > 46: INTCONbits.GIEH = 1; //enable > interrupts > 00004C 8EF2 BSF 0xff2, 0x7, ACCESS > 47: > 48: T1CONbits.TMR1ON = 0; > 00004E 90CD BCF 0xfcd, 0, ACCESS > 49: TMR1H = 0x00; > 000050 6ACF CLRF 0xfcf, ACCESS > 50: TMR1L = 0x00; > 000052 6ACE CLRF 0xfce, ACCESS > 51: T1CONbits.TMR1ON = 1; > 000054 80CD BSF 0xfcd, 0, ACCESS > > > << snip >> > > 67: > //---------------------------------------------------------------------------- > 68: // High priority interrupt vector > 69: > 70: #pragma code HIGH_INTERRUPT_VECTOR = 0x08 > 71: void > 72: InterruptVectorHigh (void) > 73: { > 74: _asm > 75: goto InterruptHandlerHigh //jump to interrupt > routine > 000008 EF3E GOTO 0x7c > 00000A F000 NOP > 76: _endasm > 77: } > 00000C 0012 RETURN 0 > 78: > 79: > //---------------------------------------------------------------------------- > 80: // High priority interrupt routine > 81: > 82: #pragma code > 83: #pragma interrupt InterruptHandlerHigh > 84: > 85: void > 86: InterruptHandlerHigh () > 00007C CFDA MOVFF 0xfda, 0xfe4 > 00007E FFE4 NOP > 000080 CFE2 MOVFF 0xfe2, 0xfda > 000082 FFDA NOP > 000084 52E6 MOVF 0xfe6, F, ACCESS > 87: { > 88: // INTCONbits.TMR0IF = 0; //clear > interrupt flag > 89: Flags.Bit.Timeout = 1; //indicate > timeout > 000086 0100 MOVLB 0 > 000088 8160 BSF 0x60, 0, BANKED > 90: LATAbits.LATA0 = !LATAbits.LATA0; //toggle LED on > RB0 > 00008A 7089 BTG 0xf89, 0, ACCESS > 91: // INTCONbits.INT0IF = 0; > 92: PIR1bits.TMR1IF = 0; > 00008C 909E BCF 0xf9e, 0, ACCESS > 93: } > 00008E 52E5 MOVF 0xfe5, F, ACCESS > 000090 CFE5 MOVFF 0xfe5, 0xfda > 000092 FFDA NOP > 000094 0011 RETFIE 0x1 > > Any help will something heavy being thrown against my wall. Thanks. > Dean >