micrometal
New Member
I have spent the evening trying to understand interrupts on the 20X2. I am using an AXE091 Development Board with the following code :
The interrupts, from the push buttons, are working, but unreliably. Typically only one will work a few times and then stop. After that the other input will do the same. What is wrong with the code?
I also have some specific questions :
1. The hintsetup and setintflags statements seem to me to do exactly the same thing : request an input when either of pins B.0 or B.1 goes high. But obviously they don't mean the same thing. What do they each mean?
2. On the setintflags page of the PICAXE manual this sentence appears "[A polled interrupt] is the only type of interrupt available in the PICAXE system." On the hintsetup page it says "The hardware interrupts are triggered and processed extremely quickly." I thought that a polled interrupt was not the same as a hardware interrupt. Am I mistaken?
These questions are probably not relevant, but they make me feel less confident about what I am doing.
Code:
' 20X2 interrupt testbed
#terminal 9600
#picaxe 20X2
#no_table
#no_data
symbol LED1 = B.3
symbol LED2 = B.4
hintsetup %01100110
setintflags %00000110, %00000110
sertxd("Starting ...",13,10)
main: goto main
interrupt:
sertxd("Interrupt received",13,10)
if pinB.0 = 1 then ' Test for high input on hint1
sertxd("Pin B.0",13,10)
high LED1
low LED2
endif
if pinB.1 = 1 then ' Test for high input on hint2
sertxd("Pin B.1",13,10)
low LED1
high LED2
endif
pause 2000 ' Allow input to clear
hint1flag = 0 ' Reset all interrupt settings
hint2flag = 0
hintsetup %01100110
setintflags %00000110, %00000110
return
I also have some specific questions :
1. The hintsetup and setintflags statements seem to me to do exactly the same thing : request an input when either of pins B.0 or B.1 goes high. But obviously they don't mean the same thing. What do they each mean?
2. On the setintflags page of the PICAXE manual this sentence appears "[A polled interrupt] is the only type of interrupt available in the PICAXE system." On the hintsetup page it says "The hardware interrupts are triggered and processed extremely quickly." I thought that a polled interrupt was not the same as a hardware interrupt. Am I mistaken?
These questions are probably not relevant, but they make me feel less confident about what I am doing.