Re: Which interrupt ?
Just thinking out loud here . . . when the interrupt (IOC) occurs you want to read the port, & save it to a temp variable. in your main loop read the variable & act early on, if your main loop is long and busy then check often. I would not act in the ISR unless critical, just to keep the ISR short & sweet, if it is critical, if micro second response is required then act there.
example;
Code:
switchVar var byte ' var to store port value
doSomething var byte ' counter var
main:
do this . . . bla bla 'your code
gosub Check
do more . . .' more yourcode
for doSomething = 0 to 50
gosub check
yourcode
next doSomething
morecode . . .
gosub check
goto Main
Check:
if switchVar = 0 then
return
else
do something with the information in switchVar
switchVar = 0 ' clear the variable after work done
endif
return
You could also read the interrupt flag bit to see if interrupt has come, esp if using PBP on interrupt. Asm interrupts are so fast, they would likely be cleared before you loop ever go there though. I am sure others have better solutions, but this will get you started.
IN Conclusion:
ISR
read the port
store port value in a var
exit ISR 'assuming ISR clears IOC Flag
do something with the information in your program
Last edited by Archangel; - 7th July 2013 at 20:23.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks