This seems to be the week for x2 interrupt questions.
I have a 20x2 (c.0) using these commands:
hintsetup %00000110
setintflags %00000110, %00000110
What happens is that the INTERRUPT: subroutine does not run until BOTH hint1 and hint2 pins have been activated. In this case they are set to activate when the pin goes from a high to a low.
I can press one button, wait a while then press the other button. The INTERRUPT: routine does not run until after both buttons have been pressed.
When running DEBUG, the proper flags are set depending on which button I press.
Press button connected to hint1--flag register changes to %00001010
Press button connected to hint2--flag register changes to %00001100
However, only when the flag register = %00001110 does the INTERRUPT: routine run. Is this correct?
Below is the guts of my code:
All I am doing is counting and printing to an LCD.
After an Interrupt, the LCD should display wether the interrupt was from hint1 or hint2.
Any input would be appreciated.
Dave E
I have a 20x2 (c.0) using these commands:
hintsetup %00000110
setintflags %00000110, %00000110
What happens is that the INTERRUPT: subroutine does not run until BOTH hint1 and hint2 pins have been activated. In this case they are set to activate when the pin goes from a high to a low.
I can press one button, wait a while then press the other button. The INTERRUPT: routine does not run until after both buttons have been pressed.
When running DEBUG, the proper flags are set depending on which button I press.
Press button connected to hint1--flag register changes to %00001010
Press button connected to hint2--flag register changes to %00001100
However, only when the flag register = %00001110 does the INTERRUPT: routine run. Is this correct?
Below is the guts of my code:
All I am doing is counting and printing to an LCD.
After an Interrupt, the LCD should display wether the interrupt was from hint1 or hint2.
Code:
HINTSETUP %00000110 'MAKE B.0 OR B.1 GO HIGH TO LOW TO INTERRUPT
SETINTFLAGS %00000110,%00000110
'-------------------------- MAIN --------------------------
DO
SEROUT LCD, BAUD, (128, #WORK)
WORK = WORK + 1
DEBUG
LOOP
'-------------------------- SUBROUTINES -------------------
INTERRUPT:
DEBUG
IF HINT1FLAG = 1 THEN
SEROUT LCD, BAUD, (148, "HINT1")
ENDIF
IF HINT2FLAG = 1 THEN
SEROUT LCD, BAUD, (168, "HINT2")
ENDIF
PAUSE 2000
SEROUT LCD, BAUD, (148, " ")
SEROUT LCD, BAUD, (168, " ")
HINT1FLAG = 0
HINT2FLAG = 0
HINTFLAG = 0
HINTSETUP %00000110
SETINTFLAGS %00000110,%00000110
DEBUG
RETURN
Dave E
Last edited: