/*-------------------------------------------
项目名: 家电中央控制系统工程
程序名: 显示MCU总体程序
编写人: 杜洋
初写时间: 2005年9月5日晚20时
程序功能: 实现液晶、语音部分的人机对话和总线的通信
实现方法: 用中断实现总线接收
CPU说明: 89S52 12MHZ晶振
接口说明: (详见 初定义)
信息说明:
修改日志:
NO.1-
-------------------------------------------*/
;----------------------------------------初定义
LCDDAT EQU P2
RS EQU P3.5
RW EQU P3.6
E EQU P3.7
REDLED EQU P3.4
BACKLED EQU P3.1
PLAY EQU P1.7
STOPIN EQU P3.0
LIN EQU P3.2
SPDAT EQU P1
XX2 EQU P0.0
LT_RAM EQU 30H
LR_RAM EQU 40H
SP_RAM EQU 20H
DIS1_RAM EQU 50H
DIS2_RAM EQU 70H
DIS3_RAM EQU 60H
DIS4_RAM EQU 80H
RR1 EQU 26H
RR3 EQU 21H
RR4 EQU 22H
T0_RAM EQU 23H
QR3_RAM EQU 24H
QR2_RAM EQU 25H
LCDDISPLAY EQU 26H ;菜单显示移位寄存器
MENU_RAM EQU 27H ;菜单位置寄存器
ONOFFLCD EQU 28H
;-------------------------------------程序入口
ORG 0000H
JMP LCD_START
ORG 0003H
JMP LIN_INT0
ORG 000BH
JMP LED_T0
ORG 0030H
;--------------------------------------主程序开始
LCD_START:
SETB PLAY
MOV T0_RAM,#250
MOV TMOD,#01H
SETB ET0
MOV TL0,#0B0H ;50MS定时初值(T0计时用)
MOV TH0,#3CH ;50MS定时初值
CLR IT0
SETB EX0
SETB TR0
SETB EA
MOV DPTR,#TAB_0
CALL START_LCD
;-----自检程序
CALL DL1S
MOV MENU_RAM,#00H
MOV DPTR,#TAB_H
CALL START_LCD
CLR LCDDISPLAY
;--------------------------------------主循环体程序
LCD_LOOP:
JB ONOFFLCD,DISPLAY_PRO
LCD_LOOP_1:
JMP LCD_LOOP
;---------------------------- 菜单显示处理
DISPLAY_PRO:
MOV A,MENU_RAM
MOV DPTR,#MENUTAB_HOST
RLC A
JMP @A+DPTR
MENUNEXT:
CALL START_LCD
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
;-------------------------
MENUTAB_HOST:
JMP HOST_H ;主菜单
JMP HOST_1 ; 1,控制
JMP HOST_2 ; 2,设置
JMP HOST_3 ; 3,智能
JMP HOST_4 ; 4,帮助
MENUTAB_1:
JMP HOST_11 ;
JMP HOST_12 ;
JMP HOST_13 ;
MENUTAB_2:
JMP HOST_21 ;
JMP HOST_22 ;
JMP HOST_23 ;
MENUTAB_3:
JMP HOST_31 ;
JMP HOST_32 ;
JMP HOST_33 ;
MENUTAB_4:
JMP HOST_41 ;
JMP HOST_42 ;
JMP HOST_43 ;
;-------------------------------菜单项主流程
HOST_H: ;主菜单的适用键
MOV A,LCDDISPLAY
CJNE A,#01H,HH_H1
MOV DPTR,#TAB_1
MOV MENU_RAM,#01H
JMP MENUNEXT
HH_H1:
CJNE A,#02H,HH_H2
MOV DPTR,#TAB_2
MOV MENU_RAM,#02H
JMP MENUNEXT
HH_H2:
CJNE A,#03H,HH_H3
MOV DPTR,#TAB_3
MOV MENU_RAM,#03H
JMP MENUNEXT
HH_H3:
CJNE A,#04H,HH_H4
MOV DPTR,#TAB_4
MOV MENU_RAM,#04H
JMP MENUNEXT
HH_H4:
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
;----------------------------------------------第一层菜单
HOST_1: ;《《《控制》》》
MOV A,LCDDISPLAY ;回到主菜单
CJNE A,#0DH,HH_10
MOV DPTR,#TAB_H
MOV MENU_RAM,#00H
JMP MENUNEXT
HH_10:
MOV A,LCDDISPLAY
CJNE A,#01H,HH_11
MOV DPTR,#TAB_11
MOV MENU_RAM,#05H
JMP MENUNEXT
HH_11:
CJNE A,#02H,HH_12
MOV DPTR,#TAB_12
MOV MENU_RAM,#06H
JMP MENUNEXT
HH_12:
CJNE A,#03H,HH_13
MOV DPTR,#TAB_13
MOV MENU_RAM,#07H
JMP MENUNEXT
HH_13:
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
HOST_2: ;《《《设置》》》
MOV A,LCDDISPLAY ;回到主菜单
CJNE A,#0DH,HH_20
MOV DPTR,#TAB_H
MOV MENU_RAM,#00H
JMP MENUNEXT
HH_20:
MOV A,LCDDISPLAY
CJNE A,#01H,HH_21
MOV DPTR,#TAB_21
MOV MENU_RAM,#09H
JMP MENUNEXT
HH_21:
CJNE A,#02H,HH_22
MOV DPTR,#TAB_22
MOV MENU_RAM,#0AH
JMP MENUNEXT
HH_22:
CJNE A,#03H,HH_23
MOV DPTR,#TAB_23
MOV MENU_RAM,#0BH
JMP MENUNEXT
HH_23:
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
HOST_3: ;《《《智能》》》
MOV A,LCDDISPLAY ;回到主菜单
CJNE A,#0DH,HH_30
MOV DPTR,#TAB_H
MOV MENU_RAM,#00H
JMP MENUNEXT
HH_30:
MOV A,LCDDISPLAY
CJNE A,#01H,HH_31
MOV DPTR,#TAB_31
MOV MENU_RAM,#0CH
JMP MENUNEXT
HH_31:
CJNE A,#02H,HH_32
MOV DPTR,#TAB_32
MOV MENU_RAM,#0DH
JMP MENUNEXT
HH_32:
CJNE A,#03H,HH_33
MOV DPTR,#TAB_33
MOV MENU_RAM,#0EH
JMP MENUNEXT
HH_33:
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
HOST_4: ;《《《帮助》》》
MOV A,LCDDISPLAY ;回到主菜单
CJNE A,#0DH,HH_40
MOV DPTR,#TAB_H
MOV MENU_RAM,#00H
JMP MENUNEXT
HH_40:
MOV A,LCDDISPLAY
CJNE A,#01H,HH_41
MOV DPTR,#TAB_41
MOV MENU_RAM,#0FH
JMP MENUNEXT
HH_41:
CJNE A,#02H,HH_42
MOV DPTR,#TAB_42
MOV MENU_RAM,#10H
JMP MENUNEXT
HH_42:
CJNE A,#03H,HH_43
MOV DPTR,#TAB_43
MOV MENU_RAM,#11H
JMP MENUNEXT
HH_43:
CLR LCDDISPLAY
CLR ONOFFLCD
JMP LCD_LOOP
;----------------------------------------第二层菜单
HOST_11:
MOV DPTR,#TAB_11
MOV MENU_RAM,#04H
JMP MENUNEXT
HOST_12:
MOV DPTR,#TAB_12
MOV MENU_RAM,#04H
JMP MENUNEXT
HOST_13:
MOV DPTR,#TAB_13
MOV MENU_RAM,#04H
JMP MENUNEXT
HOST_21:
MOV DPTR,#TAB_21
MOV MENU_RAM,#07H
JMP MENUNEXT
HOST_22:
MOV DPTR,#TAB_22
MOV MENU_RAM,#07H
JMP MENUNEXT
HOST_23:
MOV DPTR,#TAB_23
MOV MENU_RAM,#07H
JMP MENUNEXT
HOST_31:
MOV DPTR,#TAB_31
MOV MENU_RAM,#0AH
JMP MENUNEXT
HOST_32:
MOV DPTR,#TAB_32
MOV MENU_RAM,#0AH
JMP MENUNEXT
HOST_33:
MOV DPTR,#TAB_33
MOV MENU_RAM,#0AH
JMP MENUNEXT
HOST_41:
MOV DPTR,#TAB_41
MOV MENU_RAM,#0DH
JMP MENUNEXT
HOST_42:
MOV DPTR,#TAB_42
MOV MENU_RAM,#0DH
JMP MENUNEXT
HOST_43:
MOV DPTR,#TAB_43
MOV MENU_RAM,#0DH
JMP MENUNEXT
;------------------------------
;----------------------------显示内容
TAB_0:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB " 欢迎使用 ----------------家电中央控制系统自检中...... "
TAB_H:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====主菜单项====3-智能 4-帮助1-控制 2-设置 "
TAB_1:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====控制选项====2-控制全部从机 1-从机选择控制 3-更新从机联接 "
TAB_2:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====设置选项====2-遥控设置 1-系统设置 3-时间设置 "
TAB_3:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====智能选项====2-温度自动控制 1-编程自动控制 3-时间自动控制 "
TAB_4:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====帮助选项====2-使用说明 1-系统自动检测 3-关于...... "
TAB_11:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAA AA2AAAAAAAAAAAAA AA4AAAAAAAAAAAAAAA"----;
DB "==从机选择控制==2- ",0FH,20H,"1- ",0FH,20H,"3- ",0FH,1FH
TAB_12:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==控制全部从机==2-关闭全部从机 1-开启全部从机 共有从机 个 "
TAB_13:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==更新从机联接== [执行]-开始更新更新从机状态报告 [取消]-退出更新"
TAB_21:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====系统设置==== "
TAB_22:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====遥控设置====1-设置遥控键值 16路遥控开关设置2-设置遥控对象 "
TAB_23:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====时间设置====2005年09月06日 数字键入后按执行 22时33分 "
TAB_31:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==编程自动控制== [执行]-打开串口通过电脑串口编程 [取消]-关闭串口 "
TAB_32:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==温度自动控制== "
TAB_33:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==时间自动控制== "
TAB_41:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==系统自动检测== "
TAB_42:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====使用说明====是由主机和多个从家电中央控制系统机组成的系统。",20H,1FH
TAB_43:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....====统完全由杜洋自行本家电中央控制系开发,产权所有。"
TAB_EORR: ;错误信息
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====系统错误====自检的错误!!!系统内部产生无法请断电后重新启动"
TAB_NEW: ;新从机加入
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "==有新从机接入==统.... 有新的从机接入系从机ID号: "
TAB_OUT: ;有从机断开
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====从机断开====已有1个从机断开 系统自检时发现--从机ID号: "
TAB_ON: ;开启了某从机
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====从机开启==== 从机已经开启....从机ID号: "
TAB_OFF: ;关闭了某从机
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_LIVE: ;自检报告显示
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_MESSAGE: ;系统状态信息
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_BESY: ;系统忙
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====系统忙碌====请耐心等候.... 系统正在内部处理----------------"
TAB_ABOUT1: ;系统开发关于。。。
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_ABOUT2:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_ABOUT3:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_NAME1: ;系统使用说明书
;--"1AAAAAAAAAAAAAAA 3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "主机可以对任意",20H,1EH,"控制,并可以实现从机进行无线开关基本智能化控制",2EH,1FH
TAB_NAME2:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB " "
TAB_NAME3:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_NAME4:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_NAME5:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_NAME6:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_W1:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_W2:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_W3:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
TAB_W4:
;--"1AAAAAAAAAAAAAAA3AAAAAAAAAAAAAAA2AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA"----;
DB "====关于....==== "
;----------------------------
START_LCD:
MOV R1,#DIS1_RAM
MOV R2,#0
START_LCD_1:
MOV A,R2
MOVC A,@A+DPTR
MOV @R1,A
INC R2
INC R1
CJNE R2,#64,START_LCD_1
CALL LCD_DISPLAY
RET
;------------------------------显示寄存器清空
CLR_RAM:
MOV R0,#DIS1_RAM ;清共64个内存单元
MOV R7,#64 ;
CLEARDISP:
MOV @R0,#00H ;
INC R0 ;
DJNZ R7,CLEARDISP ;
RET
;--------------------------------------------渐亮显示程序
LED_LOOP1: ;
CLR A
LED_LO1:
CLR BACKLED
INC A ;A加1,渐渐的增加亮的时间
CJNE A,#0FFH,E2 ;当最亮时跳出
E1:
JMP LED_OVER1 ;
E2:
MOV R7,A ;
D1:
MOV R6,#10 ;
D019:
JNB LIN,LED_OVER1
DJNZ R6,D019 ;
DJNZ R7,D1 ;
SETB BACKLED ;
JNB LIN,LED_OVER1
CPL A ;取反A
MOV R7,A ;
D2:
MOV R6,#10 ;
D029:
JNB LIN,LED_OVER1
DJNZ R6,D029 ;
DJNZ R7,D2 ;
CPL A ;取回正A
JMP LED_LO1 ;
LED_OVER1:
CLR BACKLED
RET
;--------------------------------------------------渐暗子程序
LED_LOOP2:
CLR A
LED_LO2:
SETB BACKLED
INC A
CJNE A,#0FFH,W2
W1:
JMP LED_OVER2
W2:
MOV R7,A
D11:
MOV R6,#10
D19:
JNB LIN,LED_OVER2
DJNZ R6,D19
DJNZ R7,D11
CLR BACKLED
JNB LIN,LED_OVER2
CPL A ;;
MOV R7,A
D22:
MOV R6,#10
D29:
JNB LIN,LED_OVER2
DJNZ R6,D29
DJNZ R7,D22
CPL A
JMP LED_LO2
LED_OVER2:
SETB BACKLED
RET
;---------------------------------总线发射程序
LIN_T:
CLR REDLED
CLR EA
CALL BB
MOV R0,#LT_RAM
MOV R2,#4
LINT00: ;放入数据表
MOV A,@R0
MOV R3,#8
LINT0: ;发射数据
RRC A
JC LINT1
CALL B0
JMP LINT2
LINT1:
CALL B1
LINT2:
DJNZ R3,LINT0
INC R0
DJNZ R2,LINT00
LINTEXIT: ;退出发射
SETB LIN
SETB EA
SETB REDLED
RET
;------------------------------------代码0、1发射子程序[底层]
BB: ;初始化代码
CLR LIN
CALL DL4500US
RET
B1: ;“1”的代码
SETB LIN
CALL DL1120US
CLR LIN
CALL DL560US
RET
B0: ;“0”的代码
SETB LIN
CALL DL560US
CLR LIN
CALL DL560US
RET
;======================================T0中断处理
LED_T0:
CLR EA
JNB BACKLED,LED_T0_1
CALL LED_LOOP1
LED_T0_1:
CLR BACKLED
DJNZ T0_RAM,LEDT0_OUT
CLR TR0
MOV T0_RAM,#250
CALL LED_LOOP2
LEDT0_OUT:
MOV TL0,#0B0H ;50MS定时初值(T0计时用)
MOV TH0,#3CH ;50MS定时初值
SETB EA
REti
;=========================================T0中断结束
;=========================================总线中断处理(int0)
LIN_INT0:
CLR REDLED
CLR EA ;
PUSH PSW ;
PUSH ACC
MOV RR1,R1 ;将R1的值寄存保护起来
MOV RR3,#7
II0: ;
CALL DL560US
JB LIN,INTT0EXIT ;
DJNZ RR3,II0
MOV R1,#LR_RAM ;数据载入地址及位数
AINN: ;读出数据包长度位
MOV RR3,#8 ;数据长度接收初定义
AINN0:
JNB LIN,$
CALL DL882US
MOV C,LIN
JNC AINN1
CALL DL560US
AINN1: ;数据放入寄存器
MOV A,@R1
RRC A
MOV @R1,A
DJNZ RR3,AINN0
MOV RR4,A
INC R1
INN: ;数据包正文
MOV RR3,#8
INN0:
JNB LIN,$
CALL DL882US
MOV C,LIN
JNC INN1
CALL DL560US
INN1: ;数据放入寄存器
MOV A,@R1
RRC A
MOV @R1,A
DJNZ RR3,INN0
INC R1
DJNZ RR4,INN
;----------
CLR LCDDISPLAY
SETB TR0
MOV A,LR_RAM+1
CJNE A,#03H,INTT0EXIT
MOV LCDDISPLAY,LR_RAM+3
CPL XX2
SETB ONOFFLCD
INTT0EXIT: ;退出接收
SETB LIN
MOV T0_RAM,#250
MOV R1,RR1 ;还原主程序中R1的值
POP ACC
POP PSW
SETB EA
SETB REDLED
RETI
;=========================================中断结束
;----------------------------液晶子程序
LCD_DISPLAY:
CLR REDLED
PPPP_1:
MOV QR3_RAM,#30H
CALL WRI
MOV QR3_RAM,#0CH
CALL WRI
MOV QR3_RAM,#05H
CALL WRI
MOV QR3_RAM,#01H
CALL WRI
MOV QR3_RAM,#06H
CALL WRI
PPP_1:
MOV R2,#64
MOV QR3_RAM,#80H
CALL WRI
MOV R0,#DIS1_RAM
PPP_11:
MOV A,@R0
MOV QR2_RAM,A
CALL WRD
INC R0
DJNZ R2,PPP_11
SETB REDLED
RET
;-------------------------液晶写入子程序
;写入"指令“子程序
WRI:
PUSH ACC
CLR RS
SETB RW
WRI_1:
MOV LCDDAT,#0FFH
SETB E
MOV A,LCDDAT
CLR E
JB ACC.7,WRI_1
CLR RW
MOV LCDDAT,QR3_RAM
SETB E
CLR E
POP ACC
RET
;写入"数据"子程序
WRD:
PUSH ACC
CLR RS
SETB RW
WRD_1:
MOV LCDDAT,#0FFH
SETB E
MOV A,LCDDAT
CLR E
JB ACC.7,WRD_1
SETB RS
CLR RW
MOV LCDDAT,QR2_RAM
SETB E
CLR E
POP ACC
RET
;-----------------------------------------延时子程序
;-----------
DL882US:
MOV R6,#20
D0: MOV R7,#20
DJNZ R7,$
DJNZ R6,D0
RET
DL4500US:
MOV R6,#10
DE1: MOV R7,#200
DJNZ R7,$
DJNZ R6,DE1
RET
DL560US:
MOV R6,#20
DE2: MOV R7,#12
DJNZ R7,$
DJNZ R6,DE2
RET
DL1000US:
MOV R6,#2
DE3:MOV R7,#248
DJNZ R7,$
DJNZ R6,DE3
RET
DL9000US:
CALL DL4500US
CALL DL4500US
RET
DL1120US:
CALL DL560US
CALL DL560US
RET
DL20MS: ;20毫秒延时,主要用于去抖动。(100,100)
MOV R6,#100
DL20MS_1:
MOV R7,#100
DJNZ R7,$
DJNZ R6,DL20MS_1
RET
DL60MS: ;60毫秒延时
CALL DL20MS
CALL DL20MS
CALL DL20MS
RET
DL1S: ;1秒延时,用在了开始等待。(50)
MOV R5,#50
DL1S_1:
CALL DL20MS
DJNZ R5,DL1S_1
RET
;---------------------------------------结束
END
|