;四字16*16點陣電子屏字符顯示器 AT89C5212MHz晶振
;顯示字用查表法,不占內存,用四個16*16共陽LED點陣顯示,
;效果:向上滾動顯示字,每次四個,重復循環(huán)。
;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方式傳送顯示字節(jié)
MOVIE,#82H;T0中斷允許,總中斷允許
MOVSP,#70H
LCALLDIS1;顯示準備,黑屏,1.5秒
MAIN:MOVDPTR,#TAB
LCALLMOVDISP;逐排顯示,每次四字)
MOVDPTR,#TAB
LCALLMOVDISP1;滾動顯示,每排四字)
AJMPMAIN
;
;
;********************;
;四字逐排顯示子程序;
;********************;
;每次四字移入移出顯示方式,入口時定義好DPTR值
;
MOVDISP:MOVR1,#6;顯示6排字,每排四字(R1=排數(shù))
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=排數(shù)*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;顯示字指針移一行(二字節(jié)位置)
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個字節(jié).
;
INTT0:PUSHACC
MOVTH0,#0FCH;1ms初值重裝
MOVTL0,#18H
MOVA,#97;指向第四個字行右字節(jié)
ADDA,DPL
MOVDPL,A
MOVA,#0
ADDCA,DPH
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR;查表
MOVSBUF,A;串口0方式發(fā)送
WAIT:JBCTI,GO;等待發(fā)送完畢
AJMPWAIT;
GO:MOVA,DPL;指向第四個字行左字節(jié)
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;指向前三個字行右字節(jié)
SUBBA,#31
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR;查表
MOVSBUF,A;串口0方式發(fā)送
WAIT2:JBCTI,GO2;等待發(fā)送完畢
AJMPWAIT2;
GO2:MOVA,DPL;指向前三個字行左字節(jié)
SUBBA,#1
MOVDPL,A
MOVA,DPH
SUBBA,#0
MOVDPH,A
MOVA,#0
MOVCA,@A+DPTR
MOVSBUF,A
WAIT3:JBCTI,GO3
AJMPWAIT3
GO3:DJNZR0,MLOOP;執(zhí)行三次
;
;
SETBP1.7;關行顯示,準備涮新
NOP;串口寄存器數(shù)據(jù)穩(wěn)定
SETBP1.6;產生上升沿,行數(shù)據(jù)打入輸出端
NOP;
NOP;
CLRP1.6;恢復低電平
MOVA,R2;修改顯示行地址
ORLA,#0F0H;修改顯示行地址
MOVR2,A;修改顯示行地址
MOVA,P1;修改顯示行地址
ORLA,#0FH;修改顯示行地址
ANLA,R2;修改顯示行地址
MOVP1,A;修改完成
CLRP1.7;開行顯示
INCR2;下一行掃描地址值
INCDPTR;
INCDPTR;下一行數(shù)據(jù)地址
MOVA,R2
ANLA,#0FH
JNZGO4
SETB00H;R2為10H,現(xiàn)為末行掃描,置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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--文字:是--
DB0FEH,0FFH,0F6H,0FFH,0F6H,007H,0F6H,0FFH,0EAH,0FFH,0DCH,0FFH,0BFH,001H,0FFH,0FFH
;
DB0FFH,0FFH,0C0H,003H,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,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;--文字:業(yè)--
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