电路图就不贴出来了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[page]
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;(空)
;结束动画
;-- 水纹 -- ** 宋体, 12 **
; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=128x16, 调整后为: 128x16
TAB2:DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H,080H
DB 001H,080H,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,001H,080H,003H,0C0H
DB 003H,0C0H,001H,080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,001H,080H,002H,040H,004H,020H,008H,010H
DB 008H,010H,004H,020H,002H,040H,001H,080H,000H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,001H,0C0H,006H,030H,008H,008H,008H,008H,010H,004H,020H,002H,020H,002H
DB 020H,002H,010H,004H,008H,008H,008H,008H,006H,030H,001H,0C0H,000H,000H,000H,000H
DB 003H,0C0H,00CH,030H,010H,008H,010H,008H,060H,006H,040H,002H,080H,001H,080H,001H
DB 080H,001H,080H,001H,040H,002H,060H,006H,010H,008H,010H,008H,00CH,030H,003H,0C0H
DB 000H,000H,038H,01CH,046H,062H,081H,081H,080H,001H,040H,002H,040H,002H,020H,004H
DB 020H,004H,040H,002H,040H,002H,080H,001H,081H,081H,046H,062H,038H,01CH,000H,000H
DB 0C0H,003H,0A0H,005H,058H,01EH,024H,024H,024H,024H,01EH,078H,005H,0A0H,002H,040H
DB 002H,040H,005H,0A0H,01AH,078H,024H,024H,024H,024H,058H,01AH,0A0H,005H,0C0H,003H
DB 000H,000H,0C0H,003H,0B0H,00DH,088H,011H,044H,022H,025H,0A4H,012H,048H,00DH,0B0H
DB 00DH,0B0H,012H,048H,025H,0A4H,044H,022H,088H,011H,0B0H,00DH,0C0H,003H,000H,000H
;--福-- ** 宋体, 12 **
; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=16x16, 调整后为: 16x16
TAB3:DB 0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH
DB 055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H
DB 0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H,054H,02AH,0A8H,015H,050H,00AH
DB 050H,00AH,0A8H,015H,054H,02AH,0AAH,055H,055H,0AAH,0AAH,055H,055H,0AAH,0AAH,055H
DB 0AAH,055H,054H,02AH,0A8H,015H,050H,00AH,0A0H,005H,040H,002H,080H,001H,000H,000H
DB 000H,000H,080H,001H,040H,002H,0A0H,005H,050H,00AH,0A8H,015H,054H,02AH,0AAH,055H
DB 0A0H,005H,040H,002H,091H,0F9H,000H,000H,074H,0F0H,019H,008H,031H,008H,058H,0F0H
DB 014H,000H,011H,0F8H,012H,044H,013H,0FCH,012H,044H,091H,0F9H,040H,002H,0A0H,005H
DB 020H,000H,013H,0FEH,010H,000H,0FDH,0FCH,005H,004H,009H,004H,011H,0FCH,030H,000H
DB 05BH,0FEH,096H,022H,012H,022H,013H,0FEH,012H,022H,012H,022H,013H,0FEH,012H,002H
DB 000H,004H,07FH,0C8H,000H,008H,03FH,0BFH,020H,0A0H,020H,090H,03FH,088H,000H,00CH
DB 07FH,0DAH,044H,069H,044H,048H,07FH,0C8H,044H,048H,044H,048H,07FH,0C8H,040H,048H
DB 010H,040H,010H,080H,091H,000H,073H,0FFH,014H,080H,018H,040H,040H,0FFH,05EH,092H
DB 052H,092H,052H,092H,052H,0FEH,052H,092H,052H,092H,05EH,092H,040H,0FFH,000H,000H
DB 012H,002H,013H,0FEH,012H,022H,012H,022H,013H,0FEH,012H,022H,096H,022H,05BH,0FEH
DB 030H,000H,011H,0FCH,009H,004H,005H,004H,0FDH,0FCH,010H,000H,013H,0FEH,020H,000H
TAB4:DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F8H,0FFH,0F8H,0FFH,0C0H,0FFH,0C0H
DB 0FEH,000H,0FEH,000H,0F0H,000H,0F0H,007H,0B0H,002H,0C8H,002H,048H,006H,030H,002H;STEP1
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F8H,0FFH,0F8H,0FFH,0C0H,0FFH,0C0H
DB 0FEH,000H,0FEH,000H,0F6H,000H,0F9H,007H,089H,002H,086H,001H,000H,005H,000H,002H;STEP2
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F8H,0FFH,0F8H,0FFH,0C0H,0FFH,0C0H
DB 0FEH,0C0H,0FFH,020H,0F1H,020H,0F0H,0C7H,080H,001H,080H,007H,000H,001H,000H,007H;STEP3
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F8H,0FFH,0F8H,0FFH,0D8H,0FFH,0E4H
DB 0FEH,024H,0FEH,018H,0F0H,000H,0F0H,001H,080H,001H,080H,007H,000H,005H,000H,005H;STEP4
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FBH,0FFH,0FCH,0FFH,0C4H,0FFH,0C3H
DB 0FEH,000H,0FEH,000H,0F0H,000H,0F0H,007H,080H,001H,080H,007H,000H,004H,000H,007H;STEP5
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 000H,000H,0F4H,058H,084H,0D4H,085H,052H,0F5H,052H,085H,052H,086H,054H,0F4H,058H
DB 000H,000H,022H,05EH,022H,050H,022H,050H,023H,0DEH,022H,050H,022H,050H,0FAH,05EH
END
上一篇:单片机红外遥控+步进电机+1602液晶显示c语言源程序
下一篇:基于单片机和FAT16的SD卡读写系统设计
推荐阅读最新更新时间:2024-03-16 13:14
设计资源 培训 开发板 精华推荐
- CGD和Qorvo将共同革新电机控制解决方案
- 是德科技 FieldFox 手持式分析仪配合 VDI 扩频模块,实现毫米波分析功能
- 贸泽开售可精确测量CO2水平的 英飞凌PASCO2V15 XENSIV PAS CO2 5V传感器
- 玩法进阶,浩亭让您的PCB板端连接达到新高度!
- 长城汽车研发新篇章:固态电池技术引领未来
- 纳芯微提供全场景GaN驱动IC解决方案
- 解读华为固态电池新专利,2030 叫板宁德时代?
- 让纯电/插混车抓狂?中企推全球首款-40℃可放电增混电池,不怕冷
- 智驾域控知多少:中低端车型加速上车,行泊一体方案占主体
- Foresight推出六款先进立体传感器套件 彻底改变工业和汽车3D感知