PDA

View Full Version : Problem with "on Interrupt" and PIC18F4620



philtep
- 20th September 2005, 21:18
Hello all,
I'm having an issue gettings the On Interrupt GoTo command to work.
I've tried the following:

DEFINE OSC 20

led var PORTA.2


INTCON2.6 = 1 ' Enable PORTB pullups
INTCON2.7 = 1
On Interrupt Goto myint ' Define interrupt handler
INTCON = $90 ' Enable INTE interrupt

loop: High led ' Turn LED on
Goto loop ' Do it forever


' Interrupt handler
Disable ' No interrupts past this point
myint: Low led ' If we get here, turn LED off
Pause 500 ' Wait .5 seconds
INTCON.1 = 0 ' Clear interrupt flag
Resume ' Return to main program
Enable


This is the PicBasic Pro example slightly modified for the PIC18.
It doesn't run the myint.

I've done other tests to where I monitor the value of INTCON on an LCD and the register IS getting triggered because INTCON.6 = 1 after I trigger the interrupt. Regardless tho, it doesn't execute the myint label.

Is there anything I'm doing wrong? Any specific config changes I need to get PBP to compile it correctly maybe?

Any help is greatly appreciated,

Thanks,
Philip

Bruce
- 21st September 2005, 00:40
Try: ADCON1 = 15

Does it work now?

philtep
- 21st September 2005, 00:53
Actually, I just stumbled on the fix. The clue was this warning I was getting when I compiled the code in MPLab.. it was saying the symbol _XINST_OFF_4L didn't exist. I kept looking at the P18F4620.INC and it was there, so I didn't know what was going on.

Finally, I realized that I was looking at the P18F4620.Inc from the MPLab folder and not the one the code was using, inside the PBP folder. The PBP folder one was a bit different.

After replacing the PBP file, the interrupts worked!!! I guess some other registers were wrong as well.

I guess a WORD OF CAUTION for anyone else out there with wacky problems... Use the MPlab version of the .INC file.

Bruce
- 21st September 2005, 02:24
What file did you replace?

The PBP 18F4620.inc file includes "default" config fuse settings, and includes the P18F4620.inc file in your MPLAB directory at assembly time, and the Microchip P18F4620 file includes _XINST_OFF_4L which is a perfectly valid config fuse option?