I am just starting to mess with interupts. Just to get a feel for how they work, I have the following code.
Code:
LED VAR PORTD.0
PB VAR PORTB.0
TONE VAR PORTC.3
CTONESET VAR BIT
loop1 Var BYTE
TRISD = %00000000
TRISB = %00000001
INTCON = %10010000
DEFINE OSC 10
ON INTERRUPT Goto MyInt
INTCON = $90
mainloop:
if PB = 1 then
IF CTONESET=1 then
FOR loop1 = 0 to 500
pause 1
Next loop1
gosub CTone
LED = 0
For loop1 = 0 to 1000
pause 1
next loop1
endif
endif
goto mainloop
CTONE:
Sound Tone,[88,7,91,7,99,7]
CToneSet=0
return
disable
Myint:
led = 1
CToneSet = 1
INTCON.1=0
resume
end
What I expected to happen was when I push the button on RB0, the led would light. when I let it go I wanted it to play a tone and then turn off the led. What I get is I push the button, and the LED is off. I release the button, the LED lights, the tone plays, and the LED turns off. What am I doing wrong. I know it is something simple.
Thanks!
Bookmarks