找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

求助!高手进 在线等或邮箱发送 jayhappy1314@yahoo.cn

[复制链接]
admin 发表于 2012-9-2 18:16:13 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
51单片机汇编语言的程序,控制12864LCD显示


线路图连接*DB0---P0.0* *DB4---P0.4* *RS-------------P1.0* *PSB悬空(选择串口方式);
*DB1---P0.1* *DB5---P0.5* *RW-------------P1.1* *
; *DB2---P0.2* *DB6---P0.6* *E--------------P1.2 *
; *DB3---P0.3* *DB7---P0.7* *RESET悬空
利用 伟福软件调试,老是说我的程序 在 这条语句 clr P1.1有 多余字符,麻烦高手帮我 看看次程序!若是在此程序显示字符A,怎么改写?




ORG 0000H
START: mov SP,#60h
NOP
clr P1.1
LCD:
LCALL LCDRESET ;调用系统初始化程序
LCALL HZKLIB ;汉字显示
CALL DELAY ;延时
CALL DELAY
CALL DELAY
MOV A,#01H ;指令#01H为:清除屏幕文字,把地址指针指向00H单元
CALL LCDWC
MOV DPTR,#BITMAP ;显示图形 BITMAP
CALL LCDDIS
CALL DELAY
CALL DELAY
CALL CLEAR ;清屏
MOV A,#55H
CALL LCDFILL ;全屏显示隔列相间的线条
CALL SHUAI
CALL DELAY
CALL DELAY
CALL CLEAR ;清屏
JMP START
SHUAI:
MOV 34H,#02H ;设定字符/汉字显示起始位置为第一个显示单元
MOV 36H,#02H ;设定字符/汉字显示起始位置为第一行
MOV DPTR, #TAB2 ;需要显示汉字机内码数据表
MOV 32H,#04H ;每行显示汉字个数
MOV 33H,#02H ;显示行数
MOV 35H,#00H ;清首个显示地址缓存单元
LCALL HZK_DISP ;调用汉字显示子程序
RET
HZKLIB: ;显示汉字子程序
MOV 34H,#00H ;设定字符/汉字显示起始位置为第一个显示单元
MOV 36H,#01H ;设定字符/汉字显示起始位置为第一行
MOV DPTR, #TAB ;需要显示汉字机内码数据表
MOV 32H,#08H ;每行显示汉字个数
MOV 33H,#04H ;显示行数
MOV 35H,#00H ;清首个显示地址缓存单元
LCALL HZK_DISP ;调用汉字显示子程序
RET
LCDDIS: ;图形显示子程序,该子程序可简化为一个函数调用
MOV 20H,#00H ;设定图形显示起始行单元
MOV 21H,#00H
DIS_A1:MOV 20H,#0
DIS_A2:
MOV A,#36H ;选择扩充指令集关闭图形显示
; 该指令在扩充指令集
CALL LCDWC
MOV A,21H
ADD A,#80H ;输入图形显示起始地址
CALL LCDWC
MOV A,20H
ADD A,#80H
CALL LCDWC
MOV B,A
MOV A,#30H ;重新选择基本指令集
CALL LCDWC
CLR A
MOVC A,@A+DPTR ;输入显示数据(横向高8位数据)
CALL LCDWD
INC DPTR
CLR A
MOVC A,@A+DPTR ;输入显示数据(横向低8位数据)
CALL LCDWD
INC 20H ;列地址加一
INC DPTR
MOV A,B
CJNE A,#87H,DIS_A2 ;最后一列地址为87H
INC 21H ;行地址加一
MOV A,21H
CJNE A,#20H,DIS_A1 ;最后行地址为80H+20H=0A0H
MOV 21H,#0
DIS_A3:MOV 20H,#0 ;下半部分的显示
DIS_A4:
MOV A,#36H ;选择扩充指令集关闭图形显示
CALL LCDWC
MOV A,21H
ADD A,#80H
CALL LCDWC
MOV A,20H
ADD A,#88H ;下部分 列地址首址
CALL LCDWC
MOV B,A
MOV A,#30H ;重新选择基本指令集
CALL LCDWC
CLR A
MOVC A,@A+DPTR ;输入显示数据(横向高8位数据)
CALL LCDWD
INC DPTR
CLR A
MOVC A,@A+DPTR ;输入显示数据(横向低8位数据)
CALL LCDWD
INC DPTR
INC 20H ;列地址加一
MOV A,B
CJNE A,#8FH,DIS_A4 ;最后一列地址为8FH
INC 21H ;行地址加一
MOV A,21H
CJNE A,#20H,DIS_A3 ;最后行地址为80H+20H=0A0H
RET
CLEAR: ;清除图形显示CGRAM
MOV A,#00
CALL LCDFILL
RET
LCDFILL:
MOV R4,A
MOV 20H,#0
MOV 21H,#0
LCD_A1:MOV 21H,#0
LCD_A2:
MOV A,#36H ;选择扩充指令集关闭图形显示
CALL LCDWC
;CALL LCDPOS
MOV A,20H
ADD A,#80H
CALL LCDWC
MOV A,21H
ADD A,#80H
CALL LCDWC
MOV B,A
MOV A,#30H ;重新选择基本指令集
CALL LCDWC
MOV A,R4
CALL LCDWD
CALL LCDWD
INC 21H
MOV A,B
CJNE A,#87H,LCD_A2 ;最后一列地址?87H
INC 20H
MOV A,20H
CJNE A,#20H,LCD_A1 ;最后行地址为80H+20H=0A0H
MOV 20H,#0
LCD_A3:MOV 21H,#0
LCD_A4:
MOV A,#36H
CALL LCDWC
MOV A,20H
ADD A,#80H
CALL LCDWC
MOV A,21H
ADD A,#88H
CALL LCDWC
MOV B,A
MOV A,#30H ;重新选择基本指令集
CALL LCDWC
MOV A,R4
CALL LCDWD
CALL LCDWD
INC 21H
MOV A,B
CJNE A,#8FH,LCD_A4 ;最后一列地址为8FH
INC 20H
MOV A,20H
CJNE A,#20H,LCD_A3 ;最后行地址为80H+20H=0A0H
RET
HZK_DISP: ;汉字显示子程序
MOV R1,32H
HZK10: LCALL LCDPOS ;调用调整地址单元子程序
MOV A, 35H ;设定DDRAM地址,显示位置地址
LCALL LCDWC
HZK11: CLR A ;因为要连续输入机内码高位(区码)、低位(位码)
MOVC A, @A+DPTR ;所以要输入两次数据,如果是字符就是输入两个字符字 符代码可以看说明书
LCALL LCDWD ;DATA LCDWC
INC DPTR ;显示地址会自动加一,如果连续写就不用再输入地址,空白可用某空白汉字或字符代替
CLR A
MOVC A, @A+DPTR
LCALL LCDWD
LCALL DELAY03
INC DPTR
DJNZ R1,HZK11
MOV R1,32H ;调整显示长度
INC 36H ;跳到下一行
DJNZ 33H,HZK10
RET
LCDRESET:
LCALL DELAY ;延时
;首先选择基本指令集
MOV A, #30H ;30---基本指令操作
LCALL LCDWC
MOV A,#30H ;使用8位控制界面
LCALL LCDWC
LCALL DELAY01
MOV A, #01H ;指令#01H为:清除屏幕文字,把地址指针指向00H单元
LCALL LCDWC ;
LCALL DELAY01
MOV A, #06H ;指定在资料写入或读取时,设定游标的移动方向及指定显示的移位
LCALL LCDWC
MOV A,#0CH
CALL LCDWC
LCALL DELAY01
RET
;---------------------------------------------------------
;SEARCH ADDRESS -
;目的是为了转换地址单元为DDRAM地址单元,以方便 -
;定义显示位置 -
;汉字显示DDRAM位置为:第一行:80H----87H -
; 第二行:90H----97H -
; 第三行:88H----8FH -
; 第四行:98H----9FH -
;---------------------------------------------------------
LCDPOS: PUSH DPH ;地址转换子程序
PUSH DPL
PUSH A
MOV DPTR,#LINE_ADD ;LINE-ADD为地址表指针
MOV A,36H
MOVC A,@A+DPTR
ADD A,34H
MOV 35H,A
POP A
POP DPL
POP DPH
RET
LINE_ADD:
DB 00H,80H,90H,88H,98H,00H
READ: MOV P1, #0FBH ;读数据子程序
;P3--CONTRAL I/O
NOP ;P3=11111011B RS=1 R/W=1 READ DATA
SETB P1.2 ;E=E(I/O)
LCALL DELAY01
MOV A, P0 ;P1=DATA(I/O)
NOP
CLR P1.2
RET
CHK_BUSY:PUSH ACC
CLR P1.0 ;读忙状态子程序
SETB P1.1
SETB P1.2
CHK_B: NOP
JB p0.7,CHK_B
CLR P1.2
POP ACC
RET
LCDWD: ;写数据子程序
LCALL CHK_BUSY ;P3--CONTRAL I/O
NOP ;RS=1 RW=0 WRITE DATA
SETB P1.0
CLR P1.1
SETB P1.2 ;E=1
MOV p0, A ;p2=DATA(I/O)
LCALL DELAY01
NOP
CLR P1.2
NOP
MOV p0,#0FFH
RET
LCDWC: ;写指令子程序
LCALL CHK_BUSY ;以确保上一指令/数据模块已经接收处理完
NOP ;RS=0 WRITE INSTRUTION
CLR P1.0 ;RW=0
CLR P1.1
SETB P1.2 ;E=1
MOV p0, A ;p2=DATA(I/O)
LCALL DELAY01
NOP
CLR P1.2
NOP
MOV p0,#0FFH
RET

DELAY: ; 延时子程序
MOV R5,#03H
DE_1: MOV R6,#0FFH
DE_2: MOV R7,#0FFH
DE_3: DJNZ R7,DE_3
DJNZ R6,DE_2
NOP
NOP
DJNZ R5, DE_1
RET
DELAY01: MOV R6, #6
DE_A: MOV R7, #0Fh
DE_B: DJNZ R7, DE_B
DJNZ R6, DE_A
RET
DELAY02: MOV R6, #6
DE_A1: MOV R7, #18h
DE_B1: DJNZ R7, DE_B1
DJNZ R6, DE_A1
RET
DELAY03: MOV R5,#03H
DE_6: MOV R6,#0BFH
DE_4: MOV R7,#0BFH
DE_5: DJNZ R7,DE_5
DJNZ R6,DE_4
NOP
NOP
DJNZ R5,DE_6
RET
TAB: DB "浙江师范大学电子"
DB "信息工程大帅哥欢"
DB "迎大家光临 嘿嘿"
DB "液晶是个好东西啊"
DB 00H
RET
TAB2:
DB "笑傲江湖"
DB "突出重围"
BITMAP:
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 07h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0C0h, 00h
db 00h, 07h,0FFh,0F6h,0F8h, 00h,0E0h, 70h
db 0EFh,0F5h, 7Fh,0FFh,0FFh,0FFh,0C0h, 00h
db 00h, 07h,0FFh,0F5h,0FFh,0AFh,0EFh, 7Eh
db 81h, 0Dh,0BFh,0FFh,0FFh,0FFh,0C0h, 00h
db 00h, 07h,0FFh,0ECh, 0Ch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h, 07h,0FEh, 03h, 00h, 00h, 7Eh, 02h
db 40h, 00h, 00h, 15h, 10h, 2Fh,0C0h, 00h
db 00h, 07h,0FAh, 03h, 80h, 01h,0FFh, 04h
db 40h, 00h, 00h, 05h, 10h, 1Fh,0C0h, 00h
db 00h, 07h,0FCh, 07h,0C0h, 00h, 07h, 88h
db 20h, 3Fh, 00h, 02h, 20h, 0Fh,0C0h, 00h
db 00h, 07h,0F4h, 0Fh, 40h, 00h, 0Eh, 10h
db 22h, 7Fh,0C0h, 00h, 78h, 1Fh,0C0h, 00h
db 00h, 07h,0F8h, 00h, 40h, 00h, 0Ch, 20h
db 11h,0F0h, 00h, 00h,0FCh, 17h,0C0h, 00h
db 00h, 07h,0E8h, 00h, 80h, 00h, 04h, 40h
db 08h, 30h, 00h, 00h, 82h, 0Fh,0C0h, 00h
db 00h, 07h,0F0h, 0Fh, 00h, 08h, 98h, 40h
db 04h, 38h, 00h, 00h, 80h, 0Dh,0C0h, 00h
db 00h, 07h,0F8h, 31h, 00h, 04h, 40h, 80h
db 02h, 18h, 00h, 00h, 80h, 08h,0C0h, 00h
db 00h, 07h,0E8h, 50h, 80h, 0Ah, 20h, 80h
db 01h, 10h, 00h, 00h,0C0h, 0Dh,0C0h, 00h
db 00h, 07h,0C0h, 88h, 80h, 04h, 00h, 80h
db 01h, 0Ch, 88h, 00h,0A0h, 0Fh,0C0h, 00h
db 00h, 07h,0E0h, 84h, 43h, 80h, 00h, 80h
db 00h, 81h, 10h, 1Fh, 00h, 05h,0C0h, 00h
db 00h, 07h,0F1h, 04h, 22h, 60h, 01h, 00h
db 00h, 82h, 28h, 29h, 88h, 07h,0C0h, 00h
db 00h, 07h,0A1h, 02h, 1Ch, 5Ch, 06h, 00h
db 00h, 80h, 10h, 44h, 44h, 05h,0C0h, 00h
db 00h, 07h,0E1h, 02h, 00h, 47h,0F8h, 00h
db 00h, 80h, 00h,0C2h, 02h, 03h,0C0h, 00h
db 00h, 07h,0B1h, 02h, 00h, 44h, 00h, 00h
db 00h, 40h, 03h, 42h, 00h, 06h,0C0h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h

END
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-29 04:48 , Processed in 0.053619 second(s), 11 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表