I'm new to PIC programming and found it's hard to find simple skeleton examples of how to program MCU's. I managed to piece this entire example (attached) together from the datasheet for the PIC18F1320. The code attached has a very simple example of how to get an interrupt working and some notes that might be helpful for someone starting out like me. It's built for a Junebug programmer. If any experts out there have some comments on how to improve it please do. Especially the ISR (interrupt service routine), where I tried to build an if/then style statement (if light is on turn off, if off turn on) using assembly, I think there's a better/shorter way than what I have, but can't think of it right now...
Well done, it's not easy doing things straight from the data sheet.
As far as your ISR goes, there is a much simpler way to achieve what you have done,
Code:
HighInt
;*** high priority interrupt code goes here ***
btfss INTCON,INT0IF ;Check if it was INT0
bra Exit_int
movlw 1
xorwf LATA,F
Exit_int retfie FAST
You could even remove the BRA as it's straight after it and make it,
Code:
;High priority interrupt vector
ORG 0x0008
btfss INTCON,INT0IF ;Check if it was INT0
bra Exit_int
movlw 1
xorwf LATA,F
Exit_int retfie FAST
Actually, as you only have one interrupt enabled there is no need to check which one and so,