16X16共阳LED点阵显示屏程序
扫描二维码
随时随地手机看文章
;显示字用查表法,不占内存,用四个16*16共阳LED点阵显示,
;效果:向上滚动显示字,每次四个,重复循环。
;R2:行扫描地址(从00-0FH)。
;R3:滚动显示时控制移动速度,也可控制静止显示的时间。
ORG0000H
AJMPSTART
ORG000BH;T0
AJMPINTT0
ORG0030H
;***************初始化程序;
START: MOV P2,#7FH;清LED
MOV 20H,#00H;清标志,00H为1帧扫描结束标志
CLRP1.6;串行寄存器打入输出端控制位
MOV TMOD,#01H;使用T0作16位定时器,行扫描用。
MOV TH0,#0FCH;1ms初值(12MHz)
MOV TL0,#18H
MOV SCON,#00H;串口0方式传送显示字节
MOV IE,#82H;T0中断允许,总中断允许
MOV SP,#70H
LCALLDIS1;显示准备,黑屏,1.5秒
MAIN: MOV DPTR,#TAB
LCALL MOV DISP;逐排显示,每次四字)
MOV DPTR,#TAB
LCALL MOV DISP1;滚动显示,每排四字)
AJMPMAIN
;四字逐排显示子程序;
;每次四字移入移出显示方式,入口时定义好DPTR值
MOV DISP:MOVR1,#6;显示6排字,每排四字(R1=排数)
DISLOOP: MOV R3,#100;每排显示时间1.6*100=1.6S
DIS MOV :MOVR2,#00H;第0行开始
SETBTR0;开扫描(每次一帧)
WAIT MOV :JBC00H,DISMOV1;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
AJMPWAIT MOV
DIS MOV 1:DJNZR3,DISMOV;1帧重复显示(控制显示时间)
MOV A,#128;显示字指针移一排(每排4字*32=128)
ADDA,DPL;
MOV DPL,A
MOV A,#0
ADDCA,DPH
MOV DPH,A
DECR1;R1为0,显示完
MOV A,R1
JZ MOV OUT;
AJMPDISLOOP;
MOV OUT:RET;移动显示结束
;********************;
;四字滚动显示子程序;
;每排四字向上移出显示方式,入口时定义好DPTR值
MOV DISP1:MOVR1,#255;向上移动显示6排字,每排四字(R1=排数*16)
DISLOOP1: MOV R3,#10;移动速度1.6*10=0.16S
DIS MOV 2:MOVR2,#00H;第0行开始
SETBTR0;开扫描(每次一帧)
WAIT MOV 1:JBC00H,DISMOV3;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
AJMPWAIT MOV 1
DIS MOV 3:DJNZR3,DISMOV2;1帧重复显示(控制移动速度)
INCDPTR;显示字指针移一行(二字节位置)
INCDPTR
DECR1;R1为0,显示完
MOV A,R1
JZ MOV OUT1;
AJMPDISLOOP1;
MOV OUT1:RET;移动显示结束
;*****************;
;四个字显示子程序;
;静止显示表中某四个字
DIS1: MOV R3,#5AH;静止显示时间控制(16MS*#=1.6秒)
DIS11: MOV R2,#00H;一帧扫描初始值(行地址从00-0FH)
MOV DPTR,#TAB;取表首址
SETBTR0;开扫描(每次一帧)
WAIT11:JBC00H,DIS111;为1,扫描一帧结束
AJMPWAIT11
DIS111:DJNZR3,DIS11
RET
;扫描程序;
;************;
;1MS传送一行,每行显示1毫秒,一次传送四个字的某行共8个字节.
INTT0:PUSHACC
MOV TH0,#0FCH;1ms初值重装
MOV TL0,#18H
MOV A,#97;指向第四个字行右字节
ADDA,DPL
MOV DPL,A
MOV A,#0
ADDCA,DPH
MOV DPH,A
MOV A,#0
MOV CA,@A+DPTR;查表
MOV SBUF,A;串口0方式发送
WAIT:JBCTI,GO;等待发送完毕
AJMPWAIT;
GO: MOV A,DPL;指向第四个字行左字节
SUBBA,#1
MOV DPL,A
MOV A,DPH
SUBBA,#0
MOV DPH,A
MOV A,#0
MOV CA,@A+DPTR
MOV SBUF,A
WAIT1:JBCTI,GO1
AJMPWAIT1
;
GO1: MOV R0,#03H
MLOOP: MOV A,DPL;指向前三个字行右字节
SUBBA,#31
MOV DPL,A
MOV A,DPH
SUBBA,#0
MOV DPH,A
MOV A,#0
MOV CA,@A+DPTR;查表
MOV SBUF,A;串口0方式发送
WAIT2:JBCTI,GO2;等待发送完毕
AJMPWAIT2;
GO2: MOV A,DPL;指向前三个字行左字节
SUBBA,#1
MOV DPL,A
MOV A,DPH
SUBBA,#0
MOV DPH,A
MOV A,#0
MOV CA,@A+DPTR
MOV SBUF,A
WAIT3:JBCTI,GO3
AJMPWAIT3
GO3:DJNZR0,MLOOP;执行三次
SETBP1.7;关行显示,准备涮新
NOP;串口寄存器数据稳定
SETBP1.6;产生上升沿,行数据打入输出端
NOP;
NOP;
CLRP1.6;恢复低电平
MOV A,R2;修改显示行地址
ORLA,#0F0H;修改显示行地址
MOV R2,A;修改显示行地址
MOV A,P1;修改显示行地址
ORLA,#0FH;修改显示行地址
ANLA,R2;修改显示行地址
MOV P1,A;修改完成
CLRP1.7;开行显示
INCR2;下一行扫描地址值
INCDPTR;
INCDPTR;下一行数据地址
MOV A,R2
ANLA,#0FH
JNZGO4
SETB00H;R2为10H,现为末行扫描,置1帧结束标志
MOV A,DPL;指针修正为原帧初值
SUBBA,#32
MOV DPL,A
MOV A,DPH
SUBBA,#0
MOV DPH,A
CLRTR0;一帧扫描完,关扫描
GO4:POPACC
RETI;退出
;***************;
;扫描文字表;
;***************;
;共五排字,每排四个字,前后为黑屏
TAB:
DB000H,0C0H,000H,0C0H,0FCH,0FCH,0FCH,0FCH,00DH,08CH,06DH,08CH,06BH,060H,038H,060H;
DB018H,060H,018H,060H,03CH,070H,064H,0D8H,0E1H,08CH,043H,006H,006H,000H,000H,000H;"欢"0
DB001H,080H,067H,0FCH,067H,07CH,036H,06CH,006H,06CH,0F6H,06CH,0F6H,06CH,036H,06CH;
DB036H,06CH,037H,07CH,036H,06CH,030H,060H,038H,000H,06FH,0FEH,0C7H,0FEH,000H,000H;"迎"1
DB001H,080H,001H,080H,031H,088H,019H,098H,019H,0B0H,009H,0A0H,0FFH,0FEH,0FFH,0FEH;
DB006H,0C0H,006H,0C0H,006H,0C0H,00CH,0C4H,018H,0C6H,0F0H,0FEH,060H,07CH,000H,000H;"光"2
DB000H,0C0H,018H,0C0H,0D9H,0FCH,0D9H,0FCH,0DBH,000H,0DEH,060H,0D8H,030H,0DBH,0FCH;
DB0DBH,0FCH,0DBH,06CH,0DBH,06CH,0DBH,06CH,0DBH,0FCH,01BH,0FCH,01BH,00CH,000H,000H;"临"3
DB000H,000H,0FDH,0FCH,0FDH,0FCH,058H,060H,031H,0FCH,0FDH,08CH,0FDH,0ACH,035H,0ACH;
DB031H,0ACH,031H,0ACH,031H,0ACH,030H,060H,030H,0D8H,071H,08CH,063H,006H,000H,000H;"预"4
DB060H,000H,033H,0FCH,003H,0FCH,0FBH,00CH,0FBH,00CH,01BH,00CH,033H,0FCH,033H,0FCH;
DB079H,0B0H,0FDH,0B0H,035H,0B0H,031H,0B6H,033H,036H,03EH,03EH,034H,01CH,000H,000H;"祝"5
DB003H,000H,003H,000H,003H,000H,003H,000H,07FH,0FCH,07FH,0FCH,003H,000H,003H,000H;
DB003H,000H,007H,080H,006H,0C0H,00CH,060H,018H,030H,030H,018H,060H,00CH,000H,000H;"大"6
DB003H,000H,07FH,0FCH,07FH,0FCH,060H,00CH,01FH,0F0H,01FH,0F0H,006H,018H,01FH,030H;
DB077H,060H,00DH,0F0H,03BH,0D0H,076H,0D8H,00CH,0CCH,07BH,0C4H,063H,080H,000H,000H;"家"7
DB003H,000H,01FH,0F8H,01FH,0F8H,018H,018H,01FH,0F8H,018H,018H,01FH,0FAH,018H,01EH;
DB07FH,0FCH,07FH,0F8H,000H,0D8H,003H,098H,00FH,018H,07CH,078H,070H,070H,000H,000H;"身"8
DB018H,060H,018H,060H,030H,060H,037H,0FEH,077H,0FEH,070H,0E0H,0F1H,0F0H,0B1H,0F8H;
DB033H,068H,032H,064H,037H,0FEH,03DH,0FAH,030H,060H,030H,060H,030H,060H,000H,000H;"体"9
DB030H,030H,03EH,0FCH,03EH,0FCH,066H,034H,067H,0FEH,0EDH,0FEH,0EEH,034H,06EH,0FCH;
DB062H,030H,06AH,0FCH,06EH,030H,064H,0FEH,06EH,030H,07BH,0FEH,060H,0FEH,000H,000H;"健"10
DB001H,080H,07FH,0FEH,07FH,0FEH,061H,080H,06FH,0F8H,061H,098H,07FH,0FEH,061H,098H;
DB06FH,0F8H,069H,0C0H,06DH,0D8H,067H,0B0H,06DH,09CH,0D9H,08CH,043H,080H,000H,000H;"康"11
DB000H,000H,0FFH,0FCH,0FFH,0FCH,006H,000H,006H,000H,007H,0F0H,007H,0F0H,00CH,030H;
DB00CH,030H,00CH,030H,018H,030H,018H,030H,030H,030H,061H,0E0H,0C0H,0C0H,000H,000H;"万"12
DB001H,080H,07FH,0FEH,07FH,0FEH,001H,080H,03FH,0F8H,031H,098H,03FH,0F8H,001H,080H;
DB03FH,0FCH,001H,08CH,0FFH,0FEH,001H,08CH,03FH,0FCH,001H,080H,007H,000H,000H,000H;"事"13
DB018H,000H,018H,000H,018H,0FCH,0FEH,0FCH,0FEH,0CCH,036H,0CCH,036H,0CCH,036H,0CCH;
DB066H,0CCH,036H,0CCH,01CH,0CCH,01CH,0FCH,036H,0FCH,062H,0CCH,0C0H,000H,000H,000H;"如"14
DB001H,080H,07FH,0FCH,07FH,0FCH,00CH,060H,07FH,0FEH,000H,000H,01FH,0F8H,018H,018H;
DB01FH,0F8H,018H,018H,01FH,0F8H,001H,000H,02DH,08CH,06CH,0B6H,0C7H,0F2H,000H,000H;"意"15
DB000H,000H,03FH,0F8H,03FH,0F8H,001H,080H,001H,080H,001H,080H,07FH,0FEH,07FH,0FEH;
DB001H,080H,003H,0C0H,006H,060H,00CH,030H,018H,018H,070H,00EH,060H,006H,000H,000H;"天"16
DB000H,000H,03FH,0F8H,03FH,0F8H,001H,080H,001H,080H,001H,080H,07FH,0FEH,07FH,0FEH;
DB001H,080H,003H,0C0H,006H,060H,00CH,030H,018H,018H,070H,00EH,060H,006H,000H,000H;"天"17
DB000H,000H,07FH,0FCH,07FH,0FCH,00CH,060H,00CH,060H,00CH,060H,0FFH,0FEH,0FFH,0FEH;
DB00CH,060H,00CH,060H,00CH,060H,018H,060H,018H,060H,070H,060H,020H,060H,000H,000H;"开"18
DB000H,000H,003H,000H,001H,080H,000H,080H,000H,000H,006H,010H,036H,018H,036H,00CH;
DB066H,006H,066H,006H,046H,010H,006H,018H,007H,0F8H,003H,0F0H,000H,000H,000H,000H;"心"19
END