Interrupt not firing on PIC18F

Feb 23, 2005 1 Replies

I've started tinkering with a PIC18F4680 (with CAN bus) usin microchips MPLAB C18 C compiler. I've been beating my head against problem for many hours now :evil:



I can't get interrupts to work. I have tried, TMR0, TMR1 and INT0.



have verified that TMRnIP, TMRnIE, TMRnIF and GIEH & IPEN are al HIGH yet my ISR does not get run. If I clear TMRnIF in the main loo TMRnIF is set again when the timer overflows so it appears the time is OK, the ISR just doesn't get run



I have checked the disassembly and there is a goto in 0x08 (the hig



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 priorit

level



00003C 8ED0 BSF 0xfd0, 0x7, ACCES
40: IPR1bits.TMR1IP = 1
00003E 809F BSF 0xf9f, 0, ACCES
41: PIR1bits.TMR1IF = 0
000040 909E BCF 0xf9e, 0, ACCES
42: PIE1bits.TMR1IE = 1
000042 809D BSF 0xf9d, 0, ACCES
43: TMR0H = 0; //clear time
000044 6AD7 CLRF 0xfd7, ACCES
44: TMR0L = 0; //clear time
000046 6AD6 CLRF 0xfd6, ACCES
46: INTCONbits.GIEH = 1; //enabl interrupt
00004C 8EF2 BSF 0xff2, 0x7, ACCES
47:
48: T1CONbits.TMR1ON = 0
00004E 90CD BCF 0xfcd, 0, ACCES
49: TMR1H = 0x00
000050 6ACF CLRF 0xfcf, ACCES
50: TMR1L = 0x00
000052 6ACE CLRF 0xfce, ACCES
51: T1CONbits.TMR1ON = 1
000054 80CD BSF 0xfcd, 0, ACCES



67:



//---------------------------------------------------------------------------



68: // High priority interrupt vecto
69:
70: #pragma code HIGH_INTERRUPT_VECTOR = 0x0
71: voi
72: InterruptVectorHigh (void
73:
74: _as
75: goto InterruptHandlerHigh //jump to interrup routin
000008 EF3E GOTO 0x7
00000A F000 NO
76: _endas
77:
00000C 0012 RETURN
78:
79: //---------------------------------------------------------------------------
80: // High priority interrupt routin
81:
82: #pragma cod
83: #pragma interrupt InterruptHandlerHig
84:
85: voi
86: InterruptHandlerHigh (
00007C CFDA MOVFF 0xfda, 0xfe
00007E FFE4 NO
000080 CFE2 MOVFF 0xfe2, 0xfd
000082 FFDA NO
000084 52E6 MOVF 0xfe6, F, ACCES
87:
88: // INTCONbits.TMR0IF = 0; //clea interrupt fla
89: Flags.Bit.Timeout = 1; //indicat timeou
000086 0100 MOVLB
000088 8160 BSF 0x60, 0, BANKE
90: LATAbits.LATA0 = !LATAbits.LATA0; //toggle LED o RB
00008A 7089 BTG 0xf89, 0, ACCES
91: // INTCONbits.INT0IF = 0
92: PIR1bits.TMR1IF = 0
00008C 909E BCF 0xf9e, 0, ACCES
93:
00008E 52E5 MOVF 0xfe5, F, ACCES
000090 CFE5 MOVFF 0xfe5, 0xfd
000092 FFDA NO
000094 0011 RETFIE 0x

Any help will something heavy being thrown against my wall. Thanks



Dea



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

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required