51单片机驱动16×16LED点阵显示动画汉字汇编程序
电路图就不贴出来了16×16LED点阵的典型接法。这里提供一个完整的AT89S51单片机驱动驱动led点阵显示具有动画效果的汉字的汇编程序列子.
ORG 0000H
ST: MOV A,#0FFH ;初始化
MOV P1,A
MOV P2,A
MOV P3,A
MOV P0,A
CLR A
MOV R0,#50H ;显示缓存清0
MOV R1,#20H ;控制清0的次数
ST0: MOV @R0,A
INC R0
DJNZ R1,ST0
;正文显示
CHINESE: MOV DPTR,#TAB1 ;查表指针指向TAB1
LCALL HZ
;结束动画
SCREE:
MOV DPTR,#TAB2;查表指针指向TAB2
ACALL DD
MOV DPTR,#TAB3;查表指针指向TAB3
ACALL DD
MOV DPTR,#TAB4;查表指针指向TAB4
ACALL DD
LJMP CHINESE
;显示8幅画面子程序,SCREE专用,用字模软件字要倒置(表必须深256字节)
DD: MOV B,#00H
MOV R0,#08H ;显示8幅画面
AJMP CC
CC0: MOV A,B
ADD A,#20H ;指向下一幅画面
MOV B,A
CC: MOV R7,#08H ;画面停留时间
MOV R3,B
MOV 37H,R0
LCALL ENTER
DIS00: LCALL DISPLAY
DJNZ R7,DIS00
MOV R0,37H
DJNZ R0,CC0
RET
;汉字上移子程序,可显示8个汉字,(表必须深256字节)
HZ: MOV R3,#00H ;查表偏移量
MOV R5,#81H ;查表128次
MOVBACK: MOV R4,#10H ;使显示完一个汉字
MOVBACK0: MOV R7,#02H ;一桢画面显示时间
MOV R0,#6DH ;低8位R0指向显示缓存倒数第3个字节,以备与最后1个字节交换
MOV R1,#6CH ;高8位R1指向显示缓存倒数第4个字节,以备与倒数第2个字节交换
MOV R2,#10H ;内存后移的次数
DJNZ R5,MOVBACK1
RET ;显示完该表,返回
MOVBACK1: MOV A,@R0 ;低8位被后移的内存单元数据暂存入A
INC R0 ;后移两字节
INC R0
MOV @R0,A ;放入要移的低8位数据
MOV A,R0 ;R0指向下一个要后移的内存单元
SUBB A,#04H
MOV R0,A
MOV A,@R1 ;高8位被后移的内存单元数据暂存入A
INC R1 ;后移两字节
INC R1
MOV @R1,A ;放入要移高8位的数据
MOV A,R1 ;R1指向下一个要后移的内存单元
SUBB A,#04H
MOV R1,A ;R1指向下一个要后移的内存单元
DJNZ R2,MOVBACK1 ;显示缓存数据依次后移
MOV A,R3 ;从表TAB1读入要移进50H,51H的数据
MOVC A,@A+DPTR;先给50H读数据
MOV 50H,A
MOV A,R3 ;指向下一字节
INC A
MOV R3,A
MOVC A,@A+DPTR;再给51H读数据
MOV 51H,A
MOV A,R3 ;指向下一字节
INC A
MOV R3,A
MOV 30H,R3 ;保护数据
MOV 31H,R4
MOV 32H,R5
DISMOV: LCALL DISPLAY ;显示当前数据
DJNZ R7,DISMOV
MOV R3,30H
MOV R4,31H
MOV R5,32H
DJNZ R4,MOVBACK0
MOV 30H,R3 ;保护数据
MOV 32H,R5
MOV R7,#24H ;显示当前数据延时
DISMOV0: LCALL DISPLAY
DJNZ R7,DISMOV0
MOV R3,30H
MOV R5,32H
LJMP MOVBACK
;放进一幅显示数据到显示缓存子程序,要先设好指针DPTR和R3,影响R1,R2,R3
ENTER: MOV R1,#50H ;从50H单元起把表存入
MOV R2,#20H ;查表次数
MOV A,R3
CLLOOP_: MOVC A,@A+DPTR ;查表
MOV @R1,A ;将表放进5X,6X单元
INC R1 ;R1指向下一个地址空间
MOV A,R3 ;查表指针后移
INC A
MOV R3,A ;将指针修改结果存入R3
DJNZ R2,CLLOOP_;没查完转CLLOOP_
RET
;15MS,显示子程序,一桢32个字节,影响A,R0,R1,R3,R4,R5,R6;
;http://www.51hei.com单片机网提供汉字取模工具,可显示任意汉字
DISPLAY: MOV A,#0FFH
MOV P0,A
MOV P1,A
MOV P2,A
MOV P3,A
SETB C
MOV R6,#7FH ;赋扫描字初值,左移后初值为0FEH
MOV R5,#00H ;列扫描低8位控制
MOV R0,#50H ;行的高8(p1)位要显示的数据起始地址
MOV R1,#10H ;扫描次数
DISLOOP: MOV A,@R0 ;从内存读数据
MOV P2,#0FFH ;装入数据时不显示任何东西
MOV P3,#0FFH
CPL A ;数据取反以适合显示
MOV P1,A ;送入行的高8(p1)位要显示的数据
INC R0 ;修改R0指向低8位要显示的数据
MOV A,@R0 ;读低8位要显示的数据
CPL A ;数据取反以适合显示
MOV P0,A ;送入行的低8(p0)位要显示的数据
INC R0 ;R0指向下一个高8(p0)位要显示的数据
LCALL NEXT ;调用列扫描程序
LCALL DELAY1MS ;显示延时
DJNZ R1,DISLOOP;一桢显示完返回
MOV P3,#0FFH ;全灭
RET
;列扫描子程序DISLOOP专用
NEXT: JNC NEXT1 ;C=0转扫描高8(p3)位行
MOV A,R6 ;修改扫描字
RL A
MOV R6,A
INC R5
CJNE R5,#09H,NEXT0 ;R6=#0FEH时C=0
AJMP NEXT1
BACK: RET
NEXT0: MOV P2,R6 ;扫描低8(p2)位行
AJMP BACK
NEXT1: MOV P2,#0FFH
MOV P3,R6 ;扫描高8(p3)位行
MOV A,R6 ;修改扫描字
RL A
MOV R6,A
AJMP BACK
;延时1MS子程序
DELAY1MS: MOV R3,#10
D0: MOV R4,#50
D1: DJNZ R4,D1
DJNZ R3,D0
RET
TAB1:
DB 01FH,0F8H,001H,000H,07FH,0FEH,041H,004H,01DH,070H,001H,000H,01DH,070H,000H,000H
DB 01FH,0F0H,011H,010H,01FH,0F0H,011H,010H,01FH,0F2H,001H,002H,001H,002H,000H,0FEH;電
DB 000H,000H,03FH,0F0H,000H,020H,000H,040H,000H,080H,001H,000H,001H,000H,001H,004H
DB 0FFH,0FEH,001H,000H,001H,000H,001H,000H,001H,000H,001H,000H,005H,000H,002H,000H;子
DB 008H,000H,008H,0FCH,07EH,084H,008H,084H,0FFH,094H,041H,088H,022H,080H,014H,0FEH
DB 07EH,0A4H,008H,0A4H,008H,098H,0FFH,098H,008H,0A4H,008H,0A6H,008H,0C4H,008H,080H;報
DB 000H,000H,000H,010H,03FH,0F8H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,004H,07FH,0FEH,000H,000H,000H,000H,000H,000H;二
DB 01FH,0F8H,001H,000H,07FH,0FEH,041H,004H,01DH,070H,001H,000H,01DH,070H,002H,080H
DB 004H,060H,01AH,01EH,0E1H,008H,01FH,0E0H,000H,040H,002H,080H,001H,000H,001H,000H;零
DB 01FH,0F8H,001H,000H,07FH,0FEH,041H,004H,01DH,070H,001H,000H,01DH,070H,002H,080H
DB 004H,060H,01AH,01EH,0E1H,008H,01FH,0E0H,000H,040H,002H,080H,001H,000H,001H,000H;零
DB 004H,000H,003H,000H,001H,080H,001H,000H,0FFH,0FEH,000H,000H,000H,000H,004H,080H
DB 006H,040H,004H,020H,008H,010H,008H,018H,010H,00CH,020H,00CH,040H,008H,000H,000H;六
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H;(空)
- 关于RTX51 TINY的分析与探讨(05-30)
- 浅析8051模块化编程技巧(05-28)
- 基于DSP和单片机通信的液晶显示设计方案(07-20)
- 锁相环控制及初始化简析(08-27)
- 基于MSP430自动胀管控制器的研究(09-07)
- 嵌入式C实现延时程序的不同变量的区别(03-01)