;=============================================================== ;液晶显示子程序 ;移植时注意改:
;硬件接口定义: RS BIT P2.1 RW BIT P2.0 E BIT P2.3 PSB EQU P0.3 ;PSB=H IS PARALLEL MODE ,PSB=0 IS SERIAL MODE DATA_S EQU P0 RESET EQU P2.2 ;;**************************
;数据变量定义: ;;时间: _YEAR_H EQU 20H _YEAR_L EQU 21H _MONTH EQU 22H _DAY EQU 23H
_HOUR EQU 24H _MININUT EQU 25H _SECOND EQU 26H
_PLUS EQU 27H _CHNNL EQU 28H
_R_HOUR EQU 29H _R_MIN EQU 2AH _R_SED EQU 2BH
;;地址修改: _TABP_S EQU 2FH _TABP EQU 30H _S_BIG EQU 31H _S_SMALL EQU 32H _PAG_P EQU 3AH _PAG_P3 EQU 3BH
_DPH EQU 3CH _DPL EQU 3DH
_TY EQU 3EH _TX EQU 3FH
;;地址指针: _P_MIF EQU 40H ;;按键模式地址定义: KEY_MODE EQU 50H ;;按键检测: KEY_CHECK EQU 51H ;;屏幕修改坐标: _POS EQU 52H _VAL_H EQU 53H _VAL_L EQU 54H ;;紧急事件: _ALERT EQU 55H ;;Host定义的变量: ; SYS_AD_01_LSB DB ; SYS_AD_01_MSB DB ; SYS_AD_02_LSB DB ; SYS_AD_02_MSB DB ; SYS_AD_03_LSB DB ; SYS_AD_03_MSB DB ; SYS_AD_04_LSB DB ; SYS_AD_04_MSB DB ; SYS_AD_05_LSB DB ; SYS_AD_05_MSB DB ; SYS_AD_06_LSB DB ; SYS_AD_06_MSB DB ; SYS_AD_07_LSB DB ; SYS_AD_07_MSB DB ; SYS_AD_08_LSB DB ; SYS_AD_08_MSB DB ; SYS_AD_09_LSB DB ; SYS_AD_09_MSB DB ; SYS_AD_10_LSB DB ; SYS_AD_10_MSB DB ; SYS_AD_11_LSB DB ; SYS_AD_11_MSB DB ; SYS_AD_12_LSB DB ; SYS_AD_12_MSB DB ; SYS_AD_13_LSB DB ; SYS_AD_13_MSB DB ; SYS_AD_14_LSB DB ; SYS_AD_14_MSB DB ; SYS_AD_15_LSB DB ; SYS_AD_15_MSB DB ; SYS_AD_16_LSB DB ; SYS_AD_16_MSB DB ; SYS_AD_17_LSB DB ; SYS_AD_17_MSB DB ; SYS_AD_18_LSB DB ; SYS_AD_18_MSB DB ; SYS_AD_19_LSB DB ; SYS_AD ; SYS_AD_23_MSB DB ; SYS_AD_24_LSB DB ; SYS_AD_24_MSB DB ; SYS_AD_25_LSB DB ; SYS_AD_25_MSB DB ; SYS_AD_26_LSB DB ; SYS_AD_26_MSB DB ; SYS_AD_27_LSB DB ; SYS_AD_27_MSB DB ; SYS_AD_28_LSB DB ; SYS_AD_28_MSB DB ; SYS_AD_29_LSB DB ; SYS_AD_29_MSB DB ; SYS_AD_30_LSB DB ; SYS_AD_30_MSB DB ; SYS_AD_31_LSB DB ; SYS_AD_31_MSB DB ; SYS_AD_32_LSB DB ; SYS_AD_32_MSB DB ;;***************************
;=============================================================== ;============== 程 序 代 码 区 ============== ;=============================================================== ORG 0000H JMP START ORG 0100H START: ;初始化,含初始画面 MOV SP,#07h CLR RESET CLR E setb RESET setb PSB CLR RW MOV DATA_S,#00H ;RESET ;;变量 初始化: MOV _TABP,#4 MOV _TABP_S,#0 MOV A,#_YEAR_H MOV _P_MIF,A MOV _S_BIG,#99 MOV _S_SMALL,#0 MOV _PAG_P,#0 MOV _PAG_P3,#0
MOV _DPH,#HIGH TAB_H MOV _DPL,#LOW TAB_H ;;液晶初始化: ACALL INITIL
;;****************************** ; ============调试区=============== MOV _YEAR_H,#21 MOV _YEAR_L,#00 MOV _MONTH,#05 MOV _DAY,#12 MOV _HOUR,#17 MOV _MININUT,#41 MOV _SECOND,#15 ;初始页 LCALL PAGE_N LCALL SHOW ;时间设置页------------------- LCALL PAGE_N LCALL SHOW
LCALL PAGE_N3 LCALL M_SHOW3
LCALL M_SHOW2
LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2
LCALL KEY_RIGHT LCALL M_SHOW2 LCALL M_SHOW2
;增益页----------------------- LCALL PAGE_N LCALL SHOW
LCALL PAGE_N3 LCALL M_SHOW3
LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_UP LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2 LCALL KEY_DOWN LCALL M_SHOW2
;;通道页---------------------- LCALL PAGE_N LCALL SHOW
MOV _CHNNL,#23 LCALL M_SHOW2 LCALL KEY_LEFT LCALL M_SHOW2 LCALL KEY_LEFT LCALL M_SHOW2
LCALL PAGE_N LCALL SHOW LCALL PAGE_N LCALL SHOW
LCALL PAGE_N LCALL SHOW
LCALL PAGE_N LCALL SHOW
;*************************************************** START2: ;是否紧急事件: MOV A,_ALERT ;紧急事件处理: JZ ALERT1 ;否紧急事件: MOV DPTR,#PAGE_ST LCALL SHOW
;按键是否按下: MOV A,KEY_CHECK JZ SETTING JMP START2 ;设置: SETTING: ;TIME: MOV DPTR,#PAGE_TE LCALL SHOW JMP START ALERT1: JMP ALERT ;==================================================================== ;============== 子 程 序 区 ============ ;==================================================================== ;;-----------------显示屏初始化------------- INITIL: MOV A, #30H ;30是基本指令操作 LCALL SEND_INT LCALL DELAY01
MOV A, #01H ;清除屏幕文字,把DDRAM位址计数器调整为"00" LCALL SEND_INT LCALL DELAY01
MOV A, #06H ;指定在资料写入或读取时,设定游标的移动方向及指定显示的移位 LCALL SEND_INT ;光标右移,整体显示不移动。 LCALL DELAY01
MOV A, #0eH ;指定在资料写入或读M_SHOW: MOV A, #06H ;指定在资料写入或读取时,设定游标的移动方向及指定显示的移位 LCALL SEND_INT ;光标右移,整体显示不移动。 LCALL DELAY01
MOV A, #0FH LCALL SEND_INT LCALL DELAY01 MOV A,_POS LCALL SEND_INT LCALL DELAY01 MOV A,_VAL_H LCALL SEND_DATA LCALL DELAY01
MOV A,_VAL_L LCALL SEND_DATA LCALL DELAY01
MOV A,_POS LCALL SEND_INT LCALL DELAY01
RET ;;--------------------------------------------------- M_SHOW2: MOV A,R0 PUSH ACC MOV DPH,_DPH MOV DPL,_DPL MOV A,_TABP_S MOVC A,@A+DPTR MOV _POS,A MOV R0,_P_MIF MOV A,R0 PUSH ACC MOV A,R1 PUSH ACC MOV A,#06H LCALL SEND_INT LCALL DELAY01 MOV A, #0FH LCALL SEND_INT LCALL DELAY01 MOV R0,#0 M_S3_LOP: MOV A,R0 MOVC A,@A+DPTR CJNE A,#00H,M_S_SHOW POP ACC MOV R1,A POP ACC MOV R0,A RET M_S_SHOW: MOV _POS,A INC R0 MOV A,R0 MOVC A,@A+DPTR MOV R1,A MOV A,@R1 LCALL COVERT CALL M_SHOW INC R0 SJMP M_S3_LOP ;;------------转换---------------------- ;;入口:A COVERT: PUSH ACC RLC A JC COVER2 POP ACC MOV B,#10 DIV AB ADD A,#30H MOV _VAL_H,A MOV A,B ADD A,#30H MOV _VAL_L,A RET COVER2: POP ACC CLR C SUBB A,#0 MOV _VAL_H,#2DH MOV _VAL_L,A RET ;;-----------------屏幕显示----------------- SHOW: MOV A,R1 PUSH ACC
DEC R0 MOV _TABP_S,R0 POP ACC MOV R0,A SJMP KEY_L KEY_LL: INC R0 SJMP KEY_L0 KEY_LR: POP ACC MOV A,R0
KEY_L: MOV DPTR,#TAB_H DEC _TABP DEC _TABP DEC _TABP MOV A,_TABP K_L_CON: MOVC A,@A+DPTR CJNE A,#00H,KEY_L_N DEC _TABP MOV A,_TABP MOVC A,@A+DPTR MOV _TABP,A SJMP K_L_CON KEY_L_N: CJNE A,#_DAY,KEY_L_S LCALL MODIF_ MOV _P_MIF,A SJMP KEY_L_RN KEY_L_S: MOV _P_MIF,A INC _TABP MOV A,_TABP MOVC A,@A+DPTR MOV _S_BIG,A INC _TABP MOV A,_TABP MOVC A,@A+DPTR MOV _S_SMALL,A DEC _TABP DEC _TABP KEY_L_RN: RET TAB_H: TAB_1: DB TAB_1T-TAB_H-6 DB 00H,00H,00H TAB_1P: DB _YEAR_H,63H,00H,_YEAR_L,63H,00H DB _MONTH,0CH,00H DB _DAY,00H,00H DB _HOUR,3CH,00H DB _MININUT,3CH,00H DB _SECOND,3CH,00H DB 00H,00H,00H TAB_1T: DB TAB_1-TAB_H+4 TAB_P: TAB_2: DB TAB_2T-TAB_H-6 DB 00H,00H,00H TAB_2P: DB _PLUS,5,-5 DB 00H,00H,00H TAB_2T: DB TAB_2-TAB_H+4 TAB_C: TAB_3: DB TAB_3T-TAB_H-6 DB 00H,00H,00H TAB_3P: DB _CHNNL,1,32 DB 00H,00H,00H TAB_3T: DB TAB_3-TAB_H+4 ;;-------------------- CONSISIT: ;;---------------------- KEY_UP: MOV A,R0 PUSH ACC KEY_DOWN: MOV A,R0 PUSH ACC MOV R0,_P_MIF MOV A,@R0 CJNE A,_S_SMALL,KEY_D_N MOV @R0,_S_BIG SJMP KEY_D_R KEY_D_N: DEC @R0 KEY_D_R: POP ACC MOV R0,ACC RET
;;------------------------------------------- ALERT:
;;-------------------润年----------------------- IS_YEAR: MOV A,_YEAR_L JZ IS_Y_CH MOV B,#4 DIV AB MOV A,B JZ YES_Y1 NOT_Y: MOV A,#1 RET IS_Y_CH: MOV A,_YEAR_H MOV B,#4 DIV AB MOV A,B JZ YES_Y1 JMP NOT_Y YES_Y1: MOV A,#0 RET ;;------------------月大月小---------------------------- IS_BIG_M: SUBB A,B JNZ M_NEXT MOV A,#1 RET M_NEXT: INC R0 JMP M_CHK NOT_M: MOV A,#0 RET M_TAB: DB 01H,03H,05H,07H,08H,0AH,0CH,00H; 月大表
;;------------------------------------------------------- MODIF_: PUSH ACC MOV A,_MONTH CJNE A,#2,MODFI2 LCALL IS_YEAR JNZ MOD_NOT MOV _S_BIG,#29 SJMP MOD_EXT MOD_NOT: MOV _S_BIG,#28 SJMP MOD_EXT MODFI2: LCALL IS_BIG_M JZ MOD_NOT2 MOV _S_BIG,#31 SJMP MOD_EXT MOD_NOT2: MOV _S_BIG,#30 MOD_EXT: CLR C MOV A,_DAY SUBB A,_S_BIG JC M_R MOV A,_S_BIG MOV _DAY,A M_R: MOV _S_SMALL,#00H POP ACC RET ;;------------------------------------------------- PAGE_N: PUSH B MOV DPTR,#TAB_PAG_P INC _PAG_P MOV A,_PAG_P MOVC A,@A+DPTR MOV B,A INC _PAG_P MOV A,_PAG_P MOVC A,@A+DPTR MOV DPH,B MOV DPL,A ;初始设置: LCALL DELAY01 LCALL CHK_BUSY NOP SETB RS CLR RW SETB E MOV DATA_S,A LCALL DELAY01 NOP CLR E NOP MOV DATA_S,#0FFH RET ;------------------------------------------------------------------------- READ_DATA: LCALL DELAY01 LCALL CHK_BUSY NOP SETB RS SETB RW SETB E MOV A,DATA_S LCALL DELAY01 CLR E NOP MOV DATA_S,#0FFH RET ;------------------------------------------------------------------------- SEND_INT: LCALL CHK_BUSY NOP CLR RS CLR RW SETB E MOV DATA_S,A LCALL DELAY01 NOP CLR E NOP MOV DATA_S,#0FFH RET ;--------------------------------------------------------------------------- CHK_BUSY: CLR RS SETB RW SETB E MOV B,DATA_S HERE1: JB DATA_S.7,HERE1 nop nop CLR E NOP DJNZ R5, C0 RET
DELAY01: MOV R6, #0FFh ;6 D5: MOV R7, #08h ;8 D6: DJNZ R7, D6 DJNZ R6, D5 RET
DELAY02: MOV R6, #0Fh ;6 D52: MOV R7, #18h ;18 D62: DJNZ R7, D62 DJNZ R6, D52 RET ;=============================================================== ;============== 程 序 数 据 区 ============== ;=============================================================== ;注意:第二三行要交换 PAGE_ST: DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH DB 3DH,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,3DH DB 3DH,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,3DH DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,00H
PAGE_TE: DB 3DH,20H,54H,69H,6DH,65H,20H,53H,65H,74H,74H,69H,6EH,67H,20H,3DH DB 2DH,20H,44H,3AH,33H,30H,20H,20H,20H,20H,68H,3AH,32H,34H,20H,2DH DB 2DH,20H,59H,3AH,32H,30H,30H,34H,20H,20H,4DH,3AH,30H,39H,20H,2DH DB 2DH,20H,6DH,3AH,35H,36H,20H,20H,20H,20H,73H,3AH,36H,30H,20H,2DH,00H
PAGE_PS: DB 3DH,20H,50H,6CH,75H,73H,20H,53H,65H,74H,74H,69H,6EH,67H,20H,3DH DB 2DH,20H,20H,20H,50H,6CH,75H,73H,3AH,20H,2BH,37H,20H,20H,20H,2DH DB 2DH,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,2DH DB 16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,00H
PAGE_CL: DB 3DH,43H,68H,75H,6EH,6EH,65H,6CH,53H,65H,74H,74H,69H,6EH,67H,3DH DB 2DH,20H,43H,68H,75H,6EH,6EH,65H,6CH,3AH,20H,20H,33H,32H,20H,2DH DB 2DH,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,2DH
DB 16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,16H,00H
PAGE_VW: DB 3DH,3DH,20H,56H,69H,65H,77H,20H,20H,57H,61H,76H,65H,20H,3DH,3DH DB 20h,20H,20h,20h,20h,20h,20h,20h,20h,20h,20h,20h,20h,20h,20h,20H DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,00H
PAGE_SG: DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH DB 3DH,20H,53H,74H,61H,72H,74H,69H,6EH,67H,20H,2EH,2EH,2EH,20H,3DH DB 3DH,20H,20H,20H,20H,52H,65H,63H,6FH,72H,64H,20H,20H,20H,20H,3DH
DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,00H
PAGE_TO: DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH DB 3DH,20H,20H,20H,54H,6FH,20H,53H,74H,61H,72H,74H,20H,20H,20H,3DH DB 3DH,20H,50H,72H,65H,73H,73H,20H,20H,45H,6EH,74H,72H,79H,20H,3DH
DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,00H
PAGE_RODD: DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH DB 3DH,20H,20H,20H,31H,32H,68H,20H,32H,33H,6DH,20H,32H,33H,73H,3DH DB 3DH,52H,65H,63H,6FH,72H,64H,65H,64H,3AH,20H,20H,20H,20H,20H,3DH
DB 3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,3DH,00H
END
|