circuitpro
- 19th October 2010, 03:36
I'm still a little new to DT_INTs, and am having a little trouble. I'm trying to use two interrupts, one on a hardware UART, and the second using Ext Int 2. The hardware uart is reading an RFID tag and goes on to just send the data out the debug port.
Ext Int 2 is simply a wire that, when grounded, should write some fake RFID data to my TAG string, and send that out the debug port as well.
If the External interrupt goes first, it works ONCE; but after the UART interrupt works, the data that was put in the data string is only transmitted AFTER the next data read by the uart!!
I am at a loss to understand what's happening here. Can somebody see my goof/s?
'INCLUDE FILES FOR DT INTERRUPTS
INCLUDE "DT_INTS-18.bas"
INCLUDE "ReEnterPBP-18.bas"
'======================
'CONSTANTS
'======================
MODE CON 6 'SERIN2/SEROUT2 TO USE 38400 BAUD
'======================
'VARIABLES
'======================
TP1 VAR PORTA.0 'TP1 (GC SIDE)
TP2 VAR PORTA.1 'TP2 (GC SIDE)
TP3 VAR PORTA.2 'TP3 (READER SIDE)
LED VAR PORTA.3 'ACTIVITY LED
ITP0 VAR PORTA.5 'INTERNAL TEST POINT 0
DAV VAR PORTA.6 'DAV (INT) FLAG TO GC
DATA0 VAR PORTB.0 'WIEGAND INPUT
DATA1 VAR PORTB.1 'WIEGAND INPUT
EXTINT VAR PORTB.2 'TERMINAL STRIP INTERRUPT
LEDR VAR PORTB.3 'RED LED
LEDG VAR PORTB.4 'GRN LED
BUZZ VAR PORTB.5 'BUZZER
ITP1 VAR PORTC.0 'INTERNAL TEST POINT 1
ITP2 VAR PORTC.1 'INTERNAL TEST POINT 2
DIAGIN VAR PORTC.2 'DIAG IN (DEBUGIN)
DIAGOUT VAR PORTC.3 'DIAG OUT (DEBUG)
X VAR BYTE
Y VAR BYTE
Z VAR BYTE
TAG VAR BYTE[10]
CLEAR
'INITIALIZE INTERRUPTS
ASM
INT_LIST MACRO ;IntSource,Label,Type,ResetFlag?
INT_Handler INT2_INT, _EXTTS,PBP,yes
INT_Handler RX_INT, _RDRINT,PBP,yes
ENDM
INT_CREATE ;CREATES THE INTERRUPT PROCESSOR
ENDASM
'ENABLE INTERRUPTS
@ INT_ENABLE RX_INT ;READER UART INTERRUPT
@ INT_ENABLE INT2_INT ;EXTERNAL INTERRUPT
'======================
MAIN:
'======================
PAUSE 1
GOTO MAIN
'======================
RDRINT: 'TAG READER INTERRUPT!
'======================
HSERIN [WAIT($02),STR TAG\8\$03] 'READ ENTIRE TAG
GOSUB SHOW 'SEND TAG/KEYPAD DATA TO DIAG PORT
GOSUB ERASETAG
@ INT_RETURN
'======================
EXTTS:
'======================
'WRITE TAG DATA HERE:
'00995031
TAG[0]=$30:TAG[1]=$30:TAG[2]=$39:TAG[3]=$39:TAG[4]=$35:TAG[5]=$30:TAG[6]=$33:TAG[7]=$31
GOSUB SHOW
GOSUB ERASETAG
@ INT_RETURN
'======================
SHOW:
'======================
'SHOW TAG CHARACTERS:
SEROUT2 DIAGOUT,MODE,[STR TAG,10,13] 'SEND DATA TO DIAG PORT
RETURN
ERASETAG: 'ERASE DATA
FOR Z=0 TO 10
TAG[Z]=$00
NEXT Z
RETURN
Ext Int 2 is simply a wire that, when grounded, should write some fake RFID data to my TAG string, and send that out the debug port as well.
If the External interrupt goes first, it works ONCE; but after the UART interrupt works, the data that was put in the data string is only transmitted AFTER the next data read by the uart!!
I am at a loss to understand what's happening here. Can somebody see my goof/s?
'INCLUDE FILES FOR DT INTERRUPTS
INCLUDE "DT_INTS-18.bas"
INCLUDE "ReEnterPBP-18.bas"
'======================
'CONSTANTS
'======================
MODE CON 6 'SERIN2/SEROUT2 TO USE 38400 BAUD
'======================
'VARIABLES
'======================
TP1 VAR PORTA.0 'TP1 (GC SIDE)
TP2 VAR PORTA.1 'TP2 (GC SIDE)
TP3 VAR PORTA.2 'TP3 (READER SIDE)
LED VAR PORTA.3 'ACTIVITY LED
ITP0 VAR PORTA.5 'INTERNAL TEST POINT 0
DAV VAR PORTA.6 'DAV (INT) FLAG TO GC
DATA0 VAR PORTB.0 'WIEGAND INPUT
DATA1 VAR PORTB.1 'WIEGAND INPUT
EXTINT VAR PORTB.2 'TERMINAL STRIP INTERRUPT
LEDR VAR PORTB.3 'RED LED
LEDG VAR PORTB.4 'GRN LED
BUZZ VAR PORTB.5 'BUZZER
ITP1 VAR PORTC.0 'INTERNAL TEST POINT 1
ITP2 VAR PORTC.1 'INTERNAL TEST POINT 2
DIAGIN VAR PORTC.2 'DIAG IN (DEBUGIN)
DIAGOUT VAR PORTC.3 'DIAG OUT (DEBUG)
X VAR BYTE
Y VAR BYTE
Z VAR BYTE
TAG VAR BYTE[10]
CLEAR
'INITIALIZE INTERRUPTS
ASM
INT_LIST MACRO ;IntSource,Label,Type,ResetFlag?
INT_Handler INT2_INT, _EXTTS,PBP,yes
INT_Handler RX_INT, _RDRINT,PBP,yes
ENDM
INT_CREATE ;CREATES THE INTERRUPT PROCESSOR
ENDASM
'ENABLE INTERRUPTS
@ INT_ENABLE RX_INT ;READER UART INTERRUPT
@ INT_ENABLE INT2_INT ;EXTERNAL INTERRUPT
'======================
MAIN:
'======================
PAUSE 1
GOTO MAIN
'======================
RDRINT: 'TAG READER INTERRUPT!
'======================
HSERIN [WAIT($02),STR TAG\8\$03] 'READ ENTIRE TAG
GOSUB SHOW 'SEND TAG/KEYPAD DATA TO DIAG PORT
GOSUB ERASETAG
@ INT_RETURN
'======================
EXTTS:
'======================
'WRITE TAG DATA HERE:
'00995031
TAG[0]=$30:TAG[1]=$30:TAG[2]=$39:TAG[3]=$39:TAG[4]=$35:TAG[5]=$30:TAG[6]=$33:TAG[7]=$31
GOSUB SHOW
GOSUB ERASETAG
@ INT_RETURN
'======================
SHOW:
'======================
'SHOW TAG CHARACTERS:
SEROUT2 DIAGOUT,MODE,[STR TAG,10,13] 'SEND DATA TO DIAG PORT
RETURN
ERASETAG: 'ERASE DATA
FOR Z=0 TO 10
TAG[Z]=$00
NEXT Z
RETURN