hi everyone. I wrote a program that displays text to an LCD screen (lets say print the screen, wait a second, repeat about 10 times).
On portB.0 (int) on PIC16F84 i have a pushbutton that counts the # of button presses (continued from a different question i had earlier). The hardware is setup properly because i have used it to count & display the results in the MAIN code.
What i'm trying to do is setup an interrupt where when a button is pressed, i'll go to my interrupt code, increment the counter (# of button presses), display the # of button presses to the LCD and then resume the rest of the program.
Here is mthe relevant code so far.
__________________________________________________ ____________
'Definitions
symbol LED = PORTB.1
PushButton var PORTB.0
OPTION_REG = $7f 'enable PORTB pullups
INTCON = %10010000 'enable RB0 interrupt
TRISB=%00000001
CounterA=0 'set count value to zero
on interrupt goto myint 'define interrupt handle
{
main code
}
'interrupt handling
disable 'disable interrupts while in interrupt
myint: 'counts & displays a message if there's a button pressed
CounterA=CounterA+1
Lcdout $fe, 1, "Button Presses =" ' Clear LCD screen
Lcdout $FE, $c0, #CounterA
While Pushbutton=0:Wend
INTCON.1 = 0 'clear interrupt flag
resume 'return to main program
Enable 'enables the interrupt after handler
__________________________________________________ ___________
As of right now this is what happens. if i leave the pushbutton alone, it'll run the program normally. if i press the button, it just restarts the entire sequence of code. kind of like it acknowledges the interrupt, but then doesn't do my interrupt code (or even return to the proper place where i was in the code before the interrupt). I even put END instead of RESUME at the end of the interrupt but all that happens is it starts the program over when i hit the pushbutton.
Any ideas what i'm doing wrong?
Glenn
Bookmarks