dan
12-17-01, 10:22 AM
i've been trying to program the keypad which is part of my security system project but can't seem to get it right. I've made my own keypad it seems to work fine.. the logic of my program seems correct and can compile with no problem .. but when i try to download it to the HC11 board .. NMIT0020 .. it doesn't wanna accept it ..is there a kind soul out there that could help me :)
heres the program in assembly ..
PORTA EQU $1000
PORTD EQU $1008
PORTDDR EQU $1009
PORTE EQU $100A
BIT0 EQU $01
BIT1 EQU $02
BIT2 EQU $04
BIT3 EQU $08
BIT4 EQU $10
*Bits representing respective values on keypad
* 1=B0 2=B0&B1 3=B1 4=B2 5=B2&B3
* 6=B3 7=B4 8=B4&B5 9=B5 0=B6
COMB1 EQU %00000001 ;1
COMB2 EQU %00000010 ;3
COMB3 EQU %00110000 ;8
COMB4 EQU %00001000 ;6
ORG $01F0
COUNTER RMB 1
*Main Program
ORG $0000
LDAA #%00011100
STAA PORTDDR
BEGIN LDS #$014A
LDAA #$0
STAA PORTD
STAA PORTA
COUNTIMES LDAB #$03
STAB COUNTER
DETECTIN_1 JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_1
CMPA COMB1
BEQ DETECTIN_2
MISTAKE JSR WRONG
DEC COUNTER
BEQ SIREN
JMP DETECTIN_1
DETECTIN_2 JSR DEBOUNCE
JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_2
CMPA COMB2
BNE MISTAKE
JMP BEGIN
*Wrong input subroutine
WRONG LDX #$1000
BSET $08,X BIT2
PSHX
LDX #$000B
XREG LDY #$FFFF
YREG DEY
BNE YREG
DEX
BNE XREG
PULX
BCLR $08,X BIT2
RTS
*Siren
SIREN BSET $00,X BIT4
JMP COUNTIMES
*Keypadin
KEYPADIN LDAA PORTE
RTS
*Debounce
DEBOUNCE LDX #$000B
XREG1 LDY #$FFFF
YREG1 DEY
BNE YREG1
DEX
BNE XREG1
RTS
sigh .. seems pretty hard to read from the preview eventhough i got the margin nicely aligned .. anyway heres the attached .txt file which is much easier to read
:)
heres the program in assembly ..
PORTA EQU $1000
PORTD EQU $1008
PORTDDR EQU $1009
PORTE EQU $100A
BIT0 EQU $01
BIT1 EQU $02
BIT2 EQU $04
BIT3 EQU $08
BIT4 EQU $10
*Bits representing respective values on keypad
* 1=B0 2=B0&B1 3=B1 4=B2 5=B2&B3
* 6=B3 7=B4 8=B4&B5 9=B5 0=B6
COMB1 EQU %00000001 ;1
COMB2 EQU %00000010 ;3
COMB3 EQU %00110000 ;8
COMB4 EQU %00001000 ;6
ORG $01F0
COUNTER RMB 1
*Main Program
ORG $0000
LDAA #%00011100
STAA PORTDDR
BEGIN LDS #$014A
LDAA #$0
STAA PORTD
STAA PORTA
COUNTIMES LDAB #$03
STAB COUNTER
DETECTIN_1 JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_1
CMPA COMB1
BEQ DETECTIN_2
MISTAKE JSR WRONG
DEC COUNTER
BEQ SIREN
JMP DETECTIN_1
DETECTIN_2 JSR DEBOUNCE
JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_2
CMPA COMB2
BNE MISTAKE
JMP BEGIN
*Wrong input subroutine
WRONG LDX #$1000
BSET $08,X BIT2
PSHX
LDX #$000B
XREG LDY #$FFFF
YREG DEY
BNE YREG
DEX
BNE XREG
PULX
BCLR $08,X BIT2
RTS
*Siren
SIREN BSET $00,X BIT4
JMP COUNTIMES
*Keypadin
KEYPADIN LDAA PORTE
RTS
*Debounce
DEBOUNCE LDX #$000B
XREG1 LDY #$FFFF
YREG1 DEY
BNE YREG1
DEX
BNE XREG1
RTS
sigh .. seems pretty hard to read from the preview eventhough i got the margin nicely aligned .. anyway heres the attached .txt file which is much easier to read
:)