不能更新了
LIST P=69P42
ROMSIZE=3072
;**********************************
;系统寄存器
;**********************************
IE EQU 00H;中断使能标志寄存器
IRQ EQU 01H;中断请求寄存器
T0M EQU 02H;定时器0
T0L EQU 04H;定时器0低4位
T0H EQU 05H;定时器0高4位
PORTA EQU 08H
PORTB EQU 09H
PORTC EQU 0AH;按键PORTC.0取消,PORTC.1打开输出
PORTD EQU 0BH
PORTE EQU 0CH;输出PORT
TBR EQU 0EH;查表寄存器
INX EQU 0FH;索引寄存器
DPL EQU 10H;查表指针低4位
DPM EQU 11H;查表指针中3位
DPH EQU 12H;查表指针高3位
PCCR EQU 1AH;PORTC输入/输出控制寄存器
PECR EQU 1CH;PORTE输入/输出控制寄存器
WDT EQU 1FH;看门狗定时器
;***********************************
;用户寄存器
;**********************************
AC_BACK EQU 30H;A备份寄存器
TEMP EQU 31H;临时寄存器
TEMERL_0 EQU 32H;定时时间低4位
TEMERH_0 EQU 33H;定时时间高4位
CT0 EQU 34H
CT1 EQU 35H;延时用
KEY_ST EQU 36H;键状态寄存器
CT2 EQU 37H
CT3 EQU 38H
CT4 EQU 39H
CT5 EQU 3AH
CT6 EQU 3BH
;**********************************
;程序
;**********************************
ORG 0000H
JMP RESET
RTNI
JMP TIMER_IST
RTNI
JMP PORT_IST
;************************************
;PORT_IST中断服务子程序
;************************************
PORT_IST:
STA AC_BACK,00H
LDI IRQ,00H
ORIM IE,0001B
PORT_IST_END:
LDA AC_BACK,00H
RTNI
;************************************
;TIMER_IST中断服务程序
;************************************
TIMER_IST:
STA AC_BACK,00H
LDI IRQ,00H
ANDIM IE,1011B
TIMER_IST_END:
LDA AC_BACK,00H
RTNI
;************************************
;上电程序
;************************************
RESET:
NOP
;-------------------------------------
;清用户寄存器
POWER_RESET:
LDI DPL,00H
LDI DPM,03H
LDI DPH,00H;从30H开始
POWER_RESET_1:
LDI INX,00H
ADIM DPL,01H
LDI TEMP,00H
ADCM DPM,00H
BA3 POWER_RESET_2
JMP POWER_RESET_3
POWER_RESET_2:
ADIM DPH,01H
POWER_RESET_3:
SBI DPH,01H
BNZ POWER_RESET_1
SBI DPM,04H
BNZ POWER_RESET_1;到0BFH结束
;----------------------------------------
;初始化系统寄存器
LDI T0L,0FH
LDI T0H,0EH
LDI T0M,00H
LDI PORTC,00H
LDI PCCR,00H;输入口
LDI PORTE,00H
LDI PECR,0FH;输出口
;主程序
MAIN:
;PORT_IST中断
PORT_INT_SET:
ANDIM PORTE,00H
LDI PORTA,0FH
LDI PORTB,0CH
LDI PORTC,0FH
LDI PORTD,0FH;打开上拉电阻使用下降沿中断
NOP
NOP ;等待程序稳定
LDI IRQ,00H
LDI IE,0001B;允许PORT中断
HALT
NOP
NOP
;*********************************************
;检测按键状态
KEY_CK:
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
SUB TEMP,00H
BNZ PORT_INT_SET
LDA TEMP, 00H
BA0 KEY_CK_2
JMP PORT_INT_SET
KEY_CK_2:
ORIM PORTE,0001B
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_3
NOP
KEY_CK_3:
EORIM PORTE,0011B
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_4
JMP PORT_INT_SET
NOP
KEY_CK_4:
EORIM PORTE,0110B
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_5
JMP PORT_INT_SET
NOP
KEY_CK_5:
EORIM PORTE,0011B
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_6
JMP PORT_INT_SET
NOP
KEY_CK_6:
EORIM PORTE,0111B
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_7
JMP PORT_INT_SET
NOP
KEY_CK_7:
EORIM PORTE,0111B
CALL DELAY_1
CALL DELAY_1
CALL DELAY_1
CALL DELAY_1
CALL DELAY_1
CALL DELAY_1
LDA PORTC,00H;取PORTC按键值
STA TEMP,00H;把按键值存放在临时寄存器当中
CALL DELAY
LDA PORTC,00H
STA TEMP, 00H
LDA TEMP,00H
BA0 KEY_CK_8
JMP PORT_INT_SET
NOP
KEY_CK_8:
EORIM PORTE,0111B
NOP
CALL DELAY_1
CALL DELAY_1
JMP KEY_CK
;延时去抖动
DELAY:
LDI CT0,01H
SBIM CT0,01H
BC $-1
RTNI
DELAY_1:
LDI CT2,02H
LDI CT3,0FH
LDI CT4,0FH
LDI CT5,0FH
LDI CT6,0FH
SBIM CT6,01H
BC $-1
SBIM CT5,01H
BC $-4
SBIM CT4,01H
BC $-7
SBIM CT3,01H
BC $-0AH
SBIM CT2,01H
BC $-0DH
RTNI
;********************************************
END
程序中我没有用看门狗的 |