四字16*16点阵显示程序
扫描二维码
随时随地手机看文章
;显示字用查表法,不占内存,用四个16*16共阳LED点阵显示,
;效果:向上滚动显示字,每次四个,重复循环。
;R2:行扫描地址(从00-0FH)。
;R3:滚动显示时控制移动速度,也可控制静止显示的时间。
;************;
;中断入口程序;
;************;
;
ORG0000H
LJMPSTART
ORG0003H
RETI
ORG000BH
LJMPINTT0
ORG0013H
RETI
ORG001BH
RETI
ORG0023H
RETI
ORG002BH
RETI
;
;************;
;初始化程序;
;************;
;
;
;************;
;主程序;
;************;
;
START:MOV20H,#00H;清标志,00H为1帧扫描结束标志
MOVA,#0FFH;端口初始化
MOVP1,A
MOVP2,A
MOVP3,A
MOVP0,A
CLRP1.6;串行寄存器打入输出端控制位
MOVTMOD,#01H;使用T0作16位定时器,行扫描用。
MOVTH0,#0FCH;1ms初值(12MHz)
MOVTL0,#18H
MOVSCON,#00H;串口0方式传送显示字节
MOVIE,#82H;T0中断允许,总中断允许
MOVSP,#70H
LCALLDIS1;显示准备,黑屏,1.5秒
MAIN:MOVDPTR,#TAB
LCALLMOVDISP;逐排显示,每次四字)
MOVDPTR,#TAB
LCALLMOVDISP1;滚动显示,每排四字)
AJMPMAIN
;
;
;********************;
;四字逐排显示子程序;
;********************;
;每次四字移入移出显示方式,入口时定义好DPTR值
;
MOVDISP:MOVR1,#6;显示6排字,每排四字(R1=排数)
DISLOOP:MOVR3,#100;每排显示时间1.6*100=1.6S
DISMOV:MOVR2,#00H;第0行开始
SETBTR0;开扫描(每次一帧)
WAITMOV:JBC00H,DISMOV1;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
AJMPWAITMOV
DISMOV1:DJNZR3,DISMOV;1帧重复显示(控制显示时间)
MOVA,#128;显示字指针移一排(每排4字*32=128)
ADDA,DPL;
MOVDPL,A
MOVA,#0
ADDCA,DPH
MOVDPH,A
DECR1;R1为0,显示完
MOVA,R1
JZMOVOUT;
AJMPDISLOOP;
MOVOUT:RET;移动显示结束
;
;********************;
;四字滚动显示子程序;
;********************;
;每排四字向上移出显示方式,入口时定义好DPTR值
;
MOVDISP1:MOVR1,#255;向上移动显示6排字,每排四字(R1=排数*16)
DISLOOP1:MOVR3,#10;移动速度1.6*10=0.16S
DISMOV2:MOVR2,#00H;第0行开始
SETBTR0;开扫描(每次一帧)
WAITMOV1:JBC00H,DISMOV3;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
AJMPWAITMOV1
DISMOV3:DJNZR3,DISMOV2;1帧重复显示(控制移动速度)
INCDPTR;显示字指针移一行(二字节位置)
INCDPTR
DECR1;R1为0,显示完
MOVA,R1
JZMOVOUT1;
AJMPDISLOOP1;
MOVOUT1:RET;移动显示结束
;
;
;*****************;
;四个字显示子程序;
;*****************;
;静止显示表中某四个字
DIS1:MOVR3,#5AH;静止显示时间控制(16MS*#=1.6秒)
DIS11:MOVR2,#00H;一帧扫描初始值(行地址从00-0FH)
MOVDPTR,#TAB;取表首址
SETBTR0;开扫描(每次一帧)
WAIT11:JBC00H,DIS111;为1,扫描一帧结束
AJMPWAIT11
DIS111:DJNZR3,DIS11
RET
;
;
;************;
;扫描程序;
;************;
;1MS传送一行,每行显示1毫秒,一次传送四个字的某行共8个字节.
;
INTT0:PUSHACC
MOVTH0,#0FCH;1ms初值重装
MOVTL0,#18H
MOVA,#97;指向第四个字行右字节
ADDA,DPL
MOVDPL,A
MOVA,#0
ADDCA,DPH
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR;查表
MOVSBUF,A;串口0方式发送
WAIT:JBCTI,GO;等待发送完毕
AJMPWAIT;
GO:MOVA,DPL;指向第四个字行左字节
SUBBA,#1
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR
MOVSBUF,A
WAIT1:JBCTI,GO1
AJMPWAIT1
;
GO1:MOVR0,#03H
MLOOP:MOVA,DPL;指向前三个字行右字节
SUBBA,#31
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR;查表
MOVSBUF,A;串口0方式发送
WAIT2:JBCTI,GO2;等待发送完毕
AJMPWAIT2;
GO2:MOVA,DPL;指向前三个字行左字节
SUBBA,#1
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR
MOVSBUF,A
WAIT3:JBCTI,GO3
AJMPWAIT3
GO3:DJNZR0,MLOOP;执行三次
;
;
SETBP1.7;关行显示,准备涮新
NOP;串口寄存器数据稳定
SETBP1.6;产生上升沿,行数据打入输出端
NOP;
NOP;
CLRP1.6;恢复低电平
MOVA,R2;修改显示行地址
ORLA,#0F0H;修改显示行地址
MOVR2,A;修改显示行地址
MOVA,P1;修改显示行地址
ORLA,#0FH;修改显示行地址
ANLA,R2;修改显示行地址
MOVP1,A;修改完成
CLRP1.7;开行显示
INCR2;下一行扫描地址值
INCDPTR;
INCDPTR;下一行数据地址
MOVA,R2
ANLA,#0FH
JNZGO4
SETB00H;R2为10H,现为末行扫描,置1帧结束标志
MOVA,DPL;指针修正为原帧初值
SUBBA,#32
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
CLRTR0;一帧扫描完,关扫描
GO4:POPACC
RETI;退出
;
;
;***************;
;扫描文字表;
;***************;
;共五排字,每排四个字,前后为黑屏
TAB:DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH;黑屏
DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH;黑屏
DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB0FFH,0FFH,0F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0FEH,0FFH,0FEH,0FFH;--文字:工--
DB0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,000H,001H,0FFH,0FFH,0FFH,0FFH
DB0FBH,0BFH,0FBH,0BFH,0FBH,0BFH,0FBH,0BBH,0BBH,0B9H,0DBH,0B3H,0DBH,0B7H,0EBH,0AFH;--文字:业--
DB0E3H,0AFH,0EBH,09FH,0FBH,0BFH,0FBH,0BFH,0FBH,0BBH,000H,001H,0FFH,0FFH,0FFH,0FFH
DB0FEH,0FFH,0FEH,0FFH,0DEH,0F7H,0C0H,003H,0DEH,0F7H,0DEH,0F7H,0DEH,0F7H,0DEH,0F7H;--文字:中--
DB0DEH,0F7H,0C0H,007H,0DEH,0F7H,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH
DB0E0H,00FH,0EFH,0EFH,0E0H,00FH,0EFH,0EFH,0E0H,00FH,0FFH,0FFH,000H,001H,0DDH,0FFH;--文字:最--
DB0C1H,003H,0DDH,077H,0C1H,0AFH,0DCH,0DFH,0C1H,0AFH,01DH,071H,0FCH,0FBH,0FDH,0FFH
;
DB0F7H,0DFH,0F7H,0DFH,080H,003H,0F7H,0DFH,0F0H,01FH,0F7H,0DFH,0F0H,01FH,0F7H,0DFH;--文字:基--
DB000H,001H,0F7H,0DFH,0EEH,0E7H,0C0H,011H,03EH,0FBH,0FEH,0FFH,080H,003H,0FFH,0FFH
DB0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,000H,001H,0FCH,07FH,0FCH,0BFH,0FAH,0BFH,0FAH,0DFH;--文字:本--
DB0F6H,0EFH,0EEH,0E7H,0D0H,011H,03EH,0FBH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FFH,0FFH
DB0EFH,07FH,0EFH,07FH,0DFH,07FH,083H,003H,0BAH,0FBH,0BAH,0FBH,0B9H,0FBH,083H,07BH;--文字:的--
DB0BBH,0BBH,0BBH,09BH,0BBH,0DBH,0BBH,0FBH,083H,0FBH,0BBH,0D7H,0BFH,0EFH,0FFH,0FFH
DB0FEH,0FFH,0FFH,07FH,0C0H,003H,0DFH,0FFH,0DDH,0FFH,0DEH,0F7H,0CFH,073H,0D7H,037H;--文字:应--
DB0DBH,06FH,0DBH,06FH,0D9H,0DFH,0BBH,0DFH,0BFH,0BFH,0A0H,001H,07FH,0FFH,0FFH,0FFH
;
DB0FFH,0FFH,0E0H,003H,0EFH,07BH,0EFH,07BH,0EFH,07BH,0E0H,003H,0EFH,07BH,0EFH,07BH;--文字:用--
DB0EFH,07BH,0E0H,003H,0EFH,07BH,0EFH,07BH,0DFH,07BH,0DFH,07BH,0BFH,06BH,07FH,077H
DB0FDH,0FFH,0FEH,0FFH,0FFH,07FH,000H,001H,0FDH,0FFH,0FDH,0FFH,0FCH,00FH,0FDH,0EFH;--文字:方--
DB0FBH,0EFH,0FBH,0EFH,0F7H,0EFH,0F7H,0EFH,0EFH,0EFH,0DFH,06FH,03FH,09FH,0FFH,0FFH
DB0FFH,05FH,0FFH,067H,0FFH,06FH,080H,003H,0FFH,07FH,0FFH,07FH,0FFH,07FH,0C1H,07FH;--文字:式--
DB0F7H,0BFH,0F7H,0BFH,0F7H,0BFH,0F4H,0DFH,0E3H,0DDH,08FH,0EDH,0DFH,0F5H,0FFH,0FBH
DB0F9H,0BFH,0C7H,0AFH,0F7H,0B7H,0F7H,0B7H,0F7H,0BFH,000H,001H,0F7H,0BFH,0F7H,0B7H;--文字:我--
DB0F1H,0D7H,0C7H,0CFH,037H,0DFH,0F7H,0AFH,0F6H,06DH,0F7H,0F5H,0D7H,0F9H,0EFH,0FDH
;
DB0FFH,007H,0C0H,06FH,0EDH,0EFH,0F6H,0DFH,0C0H,001H,0DDH,0FDH,0BDH,0FFH,0C0H,003H;--文字:爱--
DB0FBH,0FFH,0F8H,00FH,0F3H,0DFH,0F4H,0BFH,0EFH,03FH,09CH,0CFH,073H,0F1H,0CFH,0FBH
DB0F7H,0DFH,0F9H,0CFH,0FBH,0BFH,0C0H,007H,0DEH,0F7H,0C0H,007H,0DEH,0F7H,0DEH,0F7H;--文字:单--
DB0C0H,007H,0DEH,0F7H,0FEH,0FFH,000H,001H,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH
DB0FFH,0BFH,0EFH,0BFH,0EFH,0BFH,0EFH,0BBH,0E0H,001H,0EFH,0FFH,0EFH,0FFH,0EFH,0FFH;--文字:片--
DB0E0H,00FH,0EFH,0EFH,0EFH,0EFH,0EFH,0EFH,0DFH,0EFH,0DFH,0EFH,0BFH,0EFH,07FH,0EFH
DB0EFH,0FFH,0EFH,007H,0EFH,077H,001H,077H,0EFH,077H,0EFH,077H,0C7H,077H,0CBH,077H;--文字:机--
DB0ABH,077H,0AFH,077H,06EH,0F7H,0EEH,0F5H,0EDH,0F5H,0EDH,0F5H,0EBH,0F9H,0EFH,0FFH
;
END