Is it a correct way to deal with an interrupt?
Hi, I am trying to learn about interrupts and have a few 12C671 PICs with me. I don’t want to waste them and then learn so I request few expert opinions before I burn this code into my PIC.
I am trying to create an interrupt in such a way that when GP2 is made high -> PIC should wake up from sleep and execute the code until GP2 is held high and when it goes low – it should go back to having sweet dreams until GP2 is made high again. Following is my code:
Code:
'fuses setup
TRISIO = %011111 '// Gpio =5-bit switch inputs - Gpio.5=Output
OPTION_REG = %11000000 '// INTERRUPT ON RISING EDGE OF GP2 + Internal pull ups off
ADCON0.0=0
ADCON1=7
ON INTERRUPT GOTO encode
goto rest
Send:
Send the variables
Goto rest
rest:
while GPIO.2=1
gosub encode
wend
INTCON = %10010000 ' global ints enabled, Ext int on GP2 enabled
@ SLEEP ' put PIC to sleep
encode:
INTCON=0
Prepare the variables with values
GOTO Send
Is the above way a correct one?
Also, I want to ask very briefly about what excatly peripheral interrupts are for or if you can put a link where I can read about them in detail. Thanks
___________________
WHY things get boring when they work just fine?
Bookmarks