我个人认为,这种信号不用用中断去做,可以用软件去抖动.
发一个6502的给你看看. r1 = key_idle
[key_code] = r1
r1 = [P_IOC_Data]
r1 |= KeyControlPin
[P_IOC_Data] = r1
[P_IOC_Buffer] =r1
sc_ky01:
[keyscx] = r1
r2 = 0x0040
sc_ky02:
call ScankeyDelay
r1 = [P_IOC_Data]
r1 ^= 0x00ff
r1 &= KeyPin
cmp r1,[keyscx]
jne sc_ky01
r2 = r2 - 0x0001
jnz sc_ky02
r1 &= KeyPin
jz sc_ky03
jmp sc_ky04
sc_ky03:
//r1 = [P_IOC_Buffer]
//r1 &= KeyControlPin
//jnz sc_ky03a
//goto sc_exit
sc_ky03a:
r1 = [P_IOC_Buffer]
r1 &= KeyControlScan2Pin
jnz sc_ky03b
goto sc_exit
sc_ky03b:
r1 = [P_IOC_Buffer]
r1 &= KeyControlScan1Pin
jz sc_ky03C
r1 = [P_IOC_Buffer]
r1 &= ~KeyControlPin
r1 |= KeyControlScan2Pin // scan 2 IOC0
[P_IOC_Buffer] =r1
[P_IOC_Data] = r1
jmp sc_ky01
sc_ky03C:
r1 = [P_IOC_Buffer]
r1 &= ~KeyControlPin
r1 |= KeyControlScan1Pin
[P_IOC_Buffer] =r1
[P_IOC_Data] = r1
jmp sc_ky01
sc_ky04:
r1 = [P_IOC_Buffer]
r1 &= KeyControlScan1Pin //SCAN KEY TO IOC5
jnz sc_next1
jmp sc_scan1OK
sc_next1:
r1 = [P_IOC_Buffer]
r1 &=KeyControlScan2Pin
jz sc_ky06 //SCAN KEY TO IOC6
sc_scan1OK:
nop
r1 = [keyscx]
cmp r1,BuzzerSetPin
jnz sc_ky04a
r2 = 0x000e
jmp sc_ky09
sc_ky04a:
//-----------------------------------------
cmp r1,LockPin
jnz scan2OK
r2 = 0x000f
jmp sc_ky09
scan2OK:
r1 = [keyscx] //
//-----------------------------------------
sc_ky06:
r1 = [keyscx]
r1=r1 lsr 1
r2 = 0xffff
sc_ky07:
r2 = r2 + 0x0001
test r1,0x0001
jnz sc_ky08
r1 = r1 lsr 1
jmp sc_ky07
sc_ky08:
r1 = r1 lsr 1
jnz sc_exit
r1 = [P_IOC_Buffer]
r1 &= 0x0020
jnz sc_ky08a
r2 = r2 + 0x0004
jmp sc_ky09
sc_ky08a:
r1 = [P_IOC_Buffer]
r1 &= 0x0040
jnz sc_ky09
r2 = r2 + 0x0008
sc_ky09:
[key_code] = r2
r1 = [sys_mode]
r1 = r1 lsl 4
r1 = r1 + [key_code]
r1 = r1 + KeyTab
r1 = [r1]
[key_code] = r1
r1 = 0x0000
[cnt_sec] = r1
sc_exit:
r1 = [P_IOC_Buffer]
r1 &= 0x009f
[P_IOC_Buffer]=r1
[P_IOC_Data] = r1
retf
.endp
//================================================
// ScankeyDelay
//================================================
ScankeyDelay: .proc
r1 = 0x0010
[Scandelay] = r1
ScankeyDelay01:
r1 = [Scandelay]
r1 = r1-0x0001
[Scandelay] = r1
cmp r1,0x0000
jne ScankeyDelay01
retf
.endp |