源程序: LCD驱动 NAME LCDfunc
?PR?readLCDstate?LCDfunc SEGMENT CODE ?PR?WRDATA?LCDfunc SEGMENT CODE
?PR?LCDINIT?LCDfunc SEGMENT CODE ?PR?LCDCLEAR?LCDfunc SEGMENT CODE ?PR?_DisplayCN?LCDfunc SEGMENT CODE ?PR?_Delay?LCDfunc SEGMENT CODE
?DT?LCDfunc SEGMENT DATA
LCD_C_ADDR EQU 0FDFFH LCD_D_ADDR EQU 0FCFFH COL EQU 10H RAMAddrH EQU 00H
PUBLIC _DisplayCN, LCDINIT,LCDCLEAR PUBLIC _Delay
RSEG ?DT?LCDfunc LCD_DAT1: DS 1 LCD_DAT2: DS 1 LCD_COM: DS 1 LCDGraphRamAddrH: DS 1 LCDGraphRamAddrL: DS 1 COUNT: DS 1 RSEG ?PR?readLCDstate?LCDfunc R_ST: MOV DPTR,#LCD_C_ADDR MOVX A,@DPTR RET ST01: LCALL R_ST JNB ACC.0,ST01 JNB ACC.1,ST01 RET ST2: LCALL R_ST JNB ACC.2,ST2 RET ST3: LCALL R_ST JNB ACC.3,ST3 RET ST6: LCALL R_ST JNB ACC.6,ERR RET ERR: LJMP ST6 ;出错处理 RSEG ?PR?WRDATA?LCDfunc WR2DAT: LCALL ST01 MOV A,LCD_DAT1 LCALL SETWRDAT WR1DAT: LCALL ST01 MOV A,LCD_DAT2 LCALL SETWRDAT WR0DAT: LCALL ST01 MOV A,LCD_COM LJMP WRDAT SETWRDAT: MOV DPTR,#LCD_D_ADDR ;设置数据通道地址/数据写入入口 WRDAT: MOVX @DPTR,A RET
;RSEG ?PR?RDDATA?LCDfunc ; RDDAT: ; LCALL ST01 ; MOV DPTR,#LCD_D_ADDR ; MOVX A,@DPTR ; MOV LCD_DAT2,A ; RET
RSEG ?PR?LCDINIT?LCDfunc ;液晶初始化 LCDINIT: MOV LCD_DAT1,#00H ;设置 MOV LCD_DAT2,#00H MOV LCD_COM,#40H LCALL WR2DAT MOV LCD_DAT1,#COL MOV LCD_DAT2,#00H MOV LCD_COM,#41H LCALL WR2DAT
MOV LCD_DAT1,#00H MOV LCD_DAT2,#RAMAddrH MOV LCD_COM,#42H LCALL WR2DAT MOV LCD_DAT1,#COL MOV LCD_DAT2,#00H MOV LCD_COM,#43H ;图形宽度设置 LCALL WR2DAT MOV LCD_COM,#0A7H ;光标形状 LCALL WR0DAT MOV LCD_COM,#88H ;显示方式设置 LCALL WR0DAT MOV LCD_COM,#9CH ;启用图形显示 LCALL WR0DAT RET RSEG ?PR?LCDCLEAR?LCDfunc LCDCLEAR: MOV LCD_DAT1,#00H MOV LCD_DAT2,#00H MOV LCD_COM,#24H LCALL WR2DAT
MOV R3,#00H MOV R4,#20H MOV LCD_COM,#0B0H ;自动写方式 LCALL WR0DAT LCDCLEAR1: LCALL ST3 MOV A,#00H LCALL SETWRDAT DJNZ R3,LCDCLEAR1 DJNZ R4,LCDCLEAR1 MOV LCD_COM,#0B2H LCALL WR0DAT RET RSEG ?PR?_DisplayCN?LCDfunc _DisplayCN: MOV A,R5 ;R5 means Y. MOV B,#COL ;col = 0x20(32) MUL AB ; ?? A*B may be overflow. It should be handled carefully.
ADD A,R7 ;R7 means X. MOV R7,A MOV A,B
ADDC A,#RAMAddrH ; ADDC A,#08H MOV R5,A MOV DPTR,#CCTAB
MOV A,R3 ; FIGURE NUMBER MOV B, #20H MUL AB ; cal the offset from CCTAB or DIGITTAB . ; But A*B may be overflow. It should be handled carefully. ADD A,DPL MOV DPL,A MOV A,B ADDC A,DPH MOV DPH,A PUSH DPH PUSH DPL MOV COUNT,#10H WRI_CC1: MOV LCD_DAT1,R7 MOV LCD_DAT2,R5 MOV LCD_COM,#24H ;命令 LCALL WR2DAT POP DPL POP DPH CLR A MOVC A,@A+DPTR MOV LCD_DAT2,A MOV A,#10H ;;
MOVC A,@A+DPTR ;;
MOV LCD_DAT1,A ; INC DPTR PUSH DPH PUSH DPL MOV LCD_COM,#0C0H ;C0H vs C4H LCALL WR1DAT MOV LCD_DAT2,LCD_DAT1 ;; LCALL WR1DAT ;; MOV A,#COL ;显示宽度 ADD A,R7 MOV R7,A CLR A ADDC A,R5 MOV R5,A DJNZ COUNT,WRI_CC1 POP ACC POP ACC RET 主函数 #include <STC89C51RC_RD_PLUS.h> #include <D:DCSYLCD_ONE_okD_func.H> #define ulong unsigned long #define uint unsigned int #define uchar unsigned char
main() { LCDInit(); LCDClear(); Delay(10); Shebeiguzhang_str(4,112); Display_str3(4,0, 0); Display_str(6 ,80,28); while(1); }
液晶上显示的汉字,1秒上一次(或者叫刷新) 请教问题能出在哪里!谢谢!指点 |