首 页文档资料下载资料维修视频包年699元
请登录  |  免费注册
当前位置:精通维修下载 > 文档资料 > 家电技术 > 单元电路介绍 > 其它电路
16X16共阳LED点阵显示屏程序
来源:本站整理  作者:佚名  2011-02-05 21:44:56



;显示字用查表法,不占内存,用四个16*16共阳LED点阵显示,
;效果:向上滚动显示字,每次四个,重复循环。
;R2:行扫描地址(从00-0FH)。
;R3:滚动显示时控制移动速度,也可控制静止显示的时间。
                ORG     0000H
                AJMP    START
                ORG     000BH             ;T0
                AJMP    INTT0
                ORG     0030H
;***************初始化程序 ;
START:           MOV      P2,#7FH             ;清LED   
                 MOV      20H,#00H         ;清标志,00H为1帧扫描结束标志
                CLR     P1.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
                LCALL   DIS1            ;显示准备,黑屏,1.5秒
MAIN:            MOV      DPTR,#TAB
                LCALL    MOV DISP         ;逐排显示,每次四字)
                 MOV      DPTR,#TAB
                LCALL    MOV DISP1        ;滚动显示,每排四字)
                AJMP    MAIN
; 四字逐排显示子程序 ;
;每次四字移入移出显示方式,入口时定义好DPTR值
MOV DISP:        MOV     R1,#6           ;显示6排字,每排四字(R1=排数)
DISLOOP:         MOV      R3,#100         ;每排显示时间1.6*100=1.6S
DIS MOV :         MOV     R2,#00H         ;第0行开始
                SETB    TR0             ;开扫描(每次一帧)
WAIT MOV :        JBC     00H,DISMOV1     ;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
                AJMP    WAIT MOV
DIS MOV 1:        DJNZ    R3,DISMOV       ;1帧重复显示(控制显示时间)
                 MOV      A,#128          ;显示字指针移一排(每排4字*32=128)
                ADD     A,DPL           ;
                 MOV      DPL,A
                 MOV      A,#0
                ADDC    A,DPH
                 MOV      DPH,A
                DEC     R1              ;R1为0,显示完
                 MOV      A,R1
                JZ       MOV OUT          ;
                AJMP    DISLOOP         ;
MOV OUT:         RET                     ;移动显示结束
;********************;
; 四字滚动显示子程序 ;
;每排四字向上移出显示方式,入口时定义好DPTR值
MOV DISP1:        MOV     R1,#255          ;向上移动显示6排字,每排四字(R1=排数*16)
DISLOOP1:         MOV      R3,#10          ;移动速度1.6*10=0.16S
DIS MOV 2:         MOV     R2,#00H         ;第0行开始
                 SETB    TR0             ;开扫描(每次一帧)
WAIT MOV 1:        JBC     00H,DISMOV3     ;标志为1扫描一帧结束(16毫秒为1帧,每行1毫秒)
                 AJMP    WAIT MOV 1
DIS MOV 3:         DJNZ    R3,DISMOV2      ;1帧重复显示(控制移动速度)
                 INC     DPTR            ;显示字指针移一行(二字节位置)
                 INC     DPTR
                 DEC     R1              ;R1为0,显示完
                  MOV      A,R1
                 JZ       MOV OUT1         ;
                 AJMP    DISLOOP1        ;
MOV OUT1:         RET                     ;移动显示结束
;*****************;
; 四个字显示子程序  ;
;静止显示表中某四个字
DIS1:            MOV      R3,#5AH         ;静止显示时间控制(16MS*#=1.6秒)
DIS11:           MOV      R2,#00H         ;一帧扫描初始值(行地址从00-0FH)
                 MOV      DPTR,#TAB       ;取表首址
                SETB    TR0             ;开扫描(每次一帧)
WAIT11:         JBC     00H,DIS111      ;为1,扫描一帧结束
                AJMP    WAIT11
DIS111:         DJNZ    R3,DIS11
                RET
;  扫描程序  ;
;************;
;1MS传送一行,每行显示1毫秒,一次传送四个字的某行共8个字节.
INTT0:          PUSH    ACC
                 MOV      TH0,#0FCH       ;1ms初值重装
                 MOV      TL0,#18H
                 MOV      A,#97           ;指向第四个字行右字节
                ADD     A,DPL
                 MOV      DPL,A
                 MOV      A,#0
                ADDC    A,DPH
                 MOV      DPH,A
                 MOV      A,#0
                 MOV C     A,@A+DPTR      ;查表
                 MOV      SBUF,A          ;串口0方式发送
WAIT:           JBC     TI,GO           ;等待发送完毕
                AJMP    WAIT            ;
GO:              MOV      A,DPL           ;指向第四个字行左字节
                SUBB    A,#1
                 MOV      DPL,A
                 MOV      A,DPH
                SUBB    A,#0
                 MOV      DPH,A
                 MOV      A,#0
                 MOV C     A,@A+DPTR
                 MOV      SBUF,A
WAIT1:          JBC     TI,GO1
                AJMP    WAIT1
;
GO1:             MOV      R0,#03H
MLOOP:           MOV      A,DPL           ;指向前三个字行右字节
                SUBB    A,#31
                 MOV      DPL,A
                 MOV      A,DPH
                SUBB    A,#0
                 MOV      DPH,A
                 MOV      A,#0
                 MOV C     A,@A+DPTR      ;查表
                 MOV      SBUF,A          ;串口0方式发送
WAIT2:          JBC     TI,GO2           ;等待发送完毕
                AJMP    WAIT2            ;
GO2:             MOV      A,DPL           ;指向前三个字行左字节
                SUBB    A,#1
                 MOV      DPL,A
                 MOV      A,DPH
                SUBB    A,#0
                 MOV      DPH,A
                 MOV      A,#0
                 MOV C     A,@A+DPTR
                 MOV      SBUF,A
WAIT3:          JBC     TI,GO3
                AJMP    WAIT3
GO3:            DJNZ    R0,MLOOP        ;执行三次
                SETB    P1.7            ;关行显示,准备涮新
                NOP                     ;串口寄存器数据稳定
                SETB    P1.6            ;产生上升沿,行数据打入输出端
                NOP                     ;
                NOP                     ;
                CLR     P1.6            ;恢复低电平
                 MOV      A,R2            ;修改显示行地址
                ORL     A,#0F0H         ;修改显示行地址
                 MOV      R2,A            ;修改显示行地址
                 MOV      A,P1            ;修改显示行地址
                ORL     A,#0FH          ;修改显示行地址
                ANL     A,R2            ;修改显示行地址
                 MOV      P1,A            ;修改完成
                CLR     P1.7            ;开行显示
                INC     R2              ;下一行扫描地址值
                INC     DPTR            ;
                INC     DPTR            ;下一行数据地址
                 MOV      A,R2
                ANL     A,#0FH
                JNZ     GO4
                SETB    00H             ;R2为10H,现为末行扫描,置1帧结束标志
                 MOV      A,DPL           ;指针修正为原帧初值
                SUBB    A,#32
                 MOV      DPL,A
                 MOV      A,DPH
                SUBB    A,#0
                 MOV      DPH,A
                CLR     TR0             ;一帧扫描完,关扫描
GO4:            POP     ACC
                RETI                    ;退出
;***************;
;  扫描文字表   ;
;***************;
; 共五排字,每排四个字,前后为黑屏
TAB:    
DB 000H,0C0H,000H,0C0H,0FCH,0FCH,0FCH,0FCH,00DH,08CH,06DH,08CH,06BH,060H,038H,060H ; 
DB 018H,060H,018H,060H,03CH,070H,064H,0D8H,0E1H,08CH,043H,006H,006H,000H,000H,000H ; "欢" 0

DB 001H,080H,067H,0FCH,067H,07CH,036H,06CH,006H,06CH,0F6H,06CH,0F6H,06CH,036H,06CH ; 
DB 036H,06CH,037H,07CH,036H,06CH,030H,060H,038H,000H,06FH,0FEH,0C7H,0FEH,000H,000H ; "迎" 1

DB 001H,080H,001H,080H,031H,088H,019H,098H,019H,0B0H,009H,0A0H,0FFH,0FEH,0FFH,0FEH ; 
DB 006H,0C0H,006H,0C0H,006H,0C0H,00CH,0C4H,018H,0C6H,0F0H,0FEH,060H,07CH,000H,000H ; "光" 2

DB 000H,0C0H,018H,0C0H,0D9H,0FCH,0D9H,0FCH,0DBH,000H,0DEH,060H,0D8H,030H,0DBH,0FCH ; 
DB 0DBH,0FCH,0DBH,06CH,0DBH,06CH,0DBH,06CH,0DBH,0FCH,01BH,0FCH,01BH,00CH,000H,000H ; "临" 3

DB 000H,000H,0FDH,0FCH,0FDH,0FCH,058H,060H,031H,0FCH,0FDH,08CH,0FDH,0ACH,035H,0ACH ; 
DB 031H,0ACH,031H,0ACH,031H,0ACH,030H,060H,030H,0D8H,071H,08CH,063H,006H,000H,000H ; "预" 4

DB 060H,000H,033H,0FCH,003H,0FCH,0FBH,00CH,0FBH,00CH,01BH,00CH,033H,0FCH,033H,0FCH ; 
DB 079H,0B0H,0FDH,0B0H,035H,0B0H,031H,0B6H,033H,036H,03EH,03EH,034H,01CH,000H,000H ; "祝" 5

DB 003H,000H,003H,000H,003H,000H,003H,000H,07FH,0FCH,07FH,0FCH,003H,000H,003H,000H ; 
DB 003H,000H,007H,080H,006H,0C0H,00CH,060H,018H,030H,030H,018H,060H,00CH,000H,000H ; "大" 6

DB 003H,000H,07FH,0FCH,07FH,0FCH,060H,00CH,01FH,0F0H,01FH,0F0H,006H,018H,01FH,030H ; 
DB 077H,060H,00DH,0F0H,03BH,0D0H,076H,0D8H,00CH,0CCH,07BH,0C4H,063H,080H,000H,000H ; "家" 7

DB 003H,000H,01FH,0F8H,01FH,0F8H,018H,018H,01FH,0F8H,018H,018H,01FH,0FAH,018H,01EH ; 
DB 07FH,0FCH,07FH,0F8H,000H,0D8H,003H,098H,00FH,018H,07CH,078H,070H,070H,000H,000H ; "身" 8

DB 018H,060H,018H,060H,030H,060H,037H,0FEH,077H,0FEH,070H,0E0H,0F1H,0F0H,0B1H,0F8H ; 
DB 033H,068H,032H,064H,037H,0FEH,03DH,0FAH,030H,060H,030H,060H,030H,060H,000H,000H ; "体" 9

DB 030H,030H,03EH,0FCH,03EH,0FCH,066H,034H,067H,0FEH,0EDH,0FEH,0EEH,034H,06EH,0FCH ; 
DB 062H,030H,06AH,0FCH,06EH,030H,064H,0FEH,06EH,030H,07BH,0FEH,060H,0FEH,000H,000H ; "健" 10

DB 001H,080H,07FH,0FEH,07FH,0FEH,061H,080H,06FH,0F8H,061H,098H,07FH,0FEH,061H,098H ; 
DB 06FH,0F8H,069H,0C0H,06DH,0D8H,067H,0B0H,06DH,09CH,0D9H,08CH,043H,080H,000H,000H ; "康" 11

DB 000H,000H,0FFH,0FCH,0FFH,0FCH,006H,000H,006H,000H,007H,0F0H,007H,0F0H,00CH,030H ; 
DB 00CH,030H,00CH,030H,018H,030H,018H,030H,030H,030H,061H,0E0H,0C0H,0C0H,000H,000H ; "万" 12

DB 001H,080H,07FH,0FEH,07FH,0FEH,001H,080H,03FH,0F8H,031H,098H,03FH,0F8H,001H,080H ; 
DB 03FH,0FCH,001H,08CH,0FFH,0FEH,001H,08CH,03FH,0FCH,001H,080H,007H,000H,000H,000H ; "事" 13

DB 018H,000H,018H,000H,018H,0FCH,0FEH,0FCH,0FEH,0CCH,036H,0CCH,036H,0CCH,036H,0CCH ; 
DB 066H,0CCH,036H,0CCH,01CH,0CCH,01CH,0FCH,036H,0FCH,062H,0CCH,0C0H,000H,000H,000H ; "如" 14

DB 001H,080H,07FH,0FCH,07FH,0FCH,00CH,060H,07FH,0FEH,000H,000H,01FH,0F8H,018H,018H ; 
DB 01FH,0F8H,018H,018H,01FH,0F8H,001H,000H,02DH,08CH,06CH,0B6H,0C7H,0F2H,000H,000H ; "意" 15

DB 000H,000H,03FH,0F8H,03FH,0F8H,001H,080H,001H,080H,001H,080H,07FH,0FEH,07FH,0FEH ; 
DB 001H,080H,003H,0C0H,006H,060H,00CH,030H,018H,018H,070H,00EH,060H,006H,000H,000H ; "天" 16

DB 000H,000H,03FH,0F8H,03FH,0F8H,001H,080H,001H,080H,001H,080H,07FH,0FEH,07FH,0FEH ; 
DB 001H,080H,003H,0C0H,006H,060H,00CH,030H,018H,018H,070H,00EH,060H,006H,000H,000H ; "天" 17

DB 000H,000H,07FH,0FCH,07FH,0FCH,00CH,060H,00CH,060H,00CH,060H,0FFH,0FEH,0FFH,0FEH ; 
DB 00CH,060H,00CH,060H,00CH,060H,018H,060H,018H,060H,070H,060H,020H,060H,000H,000H ; "开" 18

DB 000H,000H,003H,000H,001H,080H,000H,080H,000H,000H,006H,010H,036H,018H,036H,00CH ; 
DB 066H,006H,066H,006H,046H,010H,006H,018H,007H,0F8H,003H,0F0H,000H,000H,000H,000H ; "心" 19

        END



关键词:

·上一文章:DS18B20温度计
·下一文章:按键控制数码管显示时间程序

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分)
Copyright © 2007-2017 down.gzweix.Com. All Rights Reserved .
页面执行时间:313,535.20000 毫秒