To use location 0018h as interrupt vector, you have to enable the interrupt priority feature by setting bit7 of RCON. Then you also have to set bit6 of INTCON (GIEL) to enable low priority interrupts. Ensure that PSPIP bit is cleared.
BTW on the PIC18 family, banksel is not required because all the special function registers are located in the access bank.
On the interrupt service routine, you can avoid using the WREG register by using the instruction:
Code:
MOVFF PORTD,PORTC
Then you don't have to worry about context saving during interrupts which was omitted in your code.
Lastly, this looks like code orginally coming from a PIC16 family. With the PIC18 family, the BRA is an optimum instruction over the GOTO because you aren't jumping too far.
On the interrupt service routine, you can avoid using the WREG register by using the instruction:
Code:
MOVFF PORTD,PORTC
Then you don't have to worry about context saving during interrupts which was omitted in your code.
Lastly, this looks like code orginally coming from a PIC16 family. With the PIC18 family, the BRA is an optimum instruction over the GOTO because you aren't jumping too far.
Instead of retfie itself. This will take care of saving Wreg, BSR, and STATUS registers.
I recommend you to use 0008h Interrupt vector instead, therefore you don't hava to "play" with setting interrupt priorities:
motion said:
To use location 0018h as interrupt vector, you have to enable the interrupt priority feature by setting bit7 of RCON. Then you also have to set bit6 of INTCON (GIEL) to enable low priority interrupts. Ensure that PSPIP bit is cleared.