正文

16X16点阵流动显示 154和2个595驱动(51汇编)06 29 更新 22013-12-20 20:57:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/enc999/54368.html

分享到:


SH_CP EQU  P2.0;
DS0  EQU  P2.1;
ST_CP EQU  P2.2;

ORG 00H
AJMP MAIN
ORG 30H
MAIN:
MOV R0,#8
MOV R4,#50   ;  
MOV DPTR,#TAB
MOV R3,#80
MAIN1:
MOV A,R2
INC A    ;先送下半列
MOVC A,@A+DPTR
ACALL WB
INC R2
MOV A,R2
DEC A ;后送上半列
MOVC A,@A+DPTR
ACALL WB

INC R2
MOV P1,R1
SETB ST_CP
CLR ST_CP
INC R1
CJNE R1,#16,MAIN1
MOV R1,#0
CJNE R2,#32,MAIN1      
MOV R2,#0
DJNZ R4,MAIN1
MOV R4,#50;50次
INC DPTR
INC DPTR
DJNZ R3,MAIN1
AJMP MAIN

WB:
CLR C
RRC A
MOV DS0,C
SETB SH_CP
CLR SH_CP
DJNZ R0,WB
MOV R0,#8
RET

TAB: 阴码 逐列 顺向
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;" ",0
DB 000H, 000H, 030H, 004H, 036H, 00EH, 037H, 03CH, 031H, 0F0H, 03FH, 0E0H, 03EH, 03AH, 000H, 013H
DB 00EH, 007H, 0FFH, 00EH, 0F8H, 01CH, 01BH, 0F8H, 01BH, 0F0H, 018H, 01CH, 01EH, 00EH, 01EH, 007H;"欢",1
DB 000H, 000H, 003H, 002H, 073H, 007H, 073H, 0FEH, 003H, 0FCH, 000H, 006H, 03FH, 0F3H, 03FH, 0F3H
DB 060H, 033H, 060H, 063H, 000H, 003H, 07FH, 0FFH, 07FH, 0FFH, 060H, 063H, 07FH, 0E3H, 07FH, 0E3H;"迎",2
DB 000H, 000H, 003H, 002H, 003H, 003H, 003H, 007H, 033H, 00EH, 03FH, 01CH, 00FH, 0F8H, 003H, 0F0H
DB 0FFH, 000H, 0FFH, 000H, 003H, 0FEH, 003H, 0FFH, 00FH, 003H, 03FH, 003H, 033H, 003H, 003H, 00FH;"光",3
DB 000H, 000H, 03FH, 0FCH, 03FH, 0FCH, 000H, 000H, 0FFH, 0FFH, 0FFH, 0FFH, 000H, 000H, 00CH, 000H
DB 01EH, 0FFH, 0F8H, 0FFH, 0F0H, 0C6H, 036H, 0FEH, 036H, 0FEH, 030H, 0C6H, 030H, 0FFH, 030H, 0FFH;"临",4

 

2012 06 29 更新


;2012 06 29

SH_CP EQU  P2.0;
DS0  EQU  P2.1;
ST_CP EQU  P2.2;

ORG 00H
AJMP MAIN
ORG 30H
MAIN:
MOV P1,#00H
MOV R0,#8
MOV R4,#50   ;  每屏反复显示50次
MOV DPTR,#TAB
MOV R3,#80   ;含空格字符共80列
MAIN1:
MOV A,R2
MOVC A,@A+DPTR
ACALL WB
INC R2
MOV A,R2
MOVC A,@A+DPTR
ACALL WB
JB F0,MAIN2
INC R2
MOV P1,R1
SETB P1.6     ;U2使能
SETB ST_CP
CLR ST_CP
INC R1
CJNE R1,#8,MAIN1
MOV R1,#0
SETB F0
AJMP MAIN1
MAIN2:
INC R2
MOV A,R1
RL A    
RL A
RL A
MOV P1,A   ;A里的数左移3 次,即R1之0~7,送P1.3~P1.5输出
SETB P1.7 ;U3使能
SETB ST_CP
CLR ST_CP
INC R1
CJNE R1,#8,MAIN1
MOV R1,#0
CLR F0
CJNE R2,#32,MAIN1
MOV R2,#0
DJNZ R4,MAIN1
MOV R4,#50;50次
INC DPTR      
INC DPTR
DJNZ R3,MAIN1
AJMP MAIN

WB:
CLR C
RRC A
MOV DS0,C
SETB SH_CP
CLR SH_CP
DJNZ R0,WB
MOV R0,#8
RET

TAB: ;黑体 逐列 顺向 阴码 
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;" ",0
DB 000H, 000H, 030H, 004H, 036H, 00EH, 037H, 03CH, 031H, 0F0H, 03FH, 0E0H, 03EH, 03AH, 000H, 013H
DB 00EH, 007H, 0FFH, 00EH, 0F8H, 01CH, 01BH, 0F8H, 01BH, 0F0H, 018H, 01CH, 01EH, 00EH, 01EH, 007H;"欢",1
DB 000H, 000H, 003H, 002H, 073H, 007H, 073H, 0FEH, 003H, 0FCH, 000H, 006H, 03FH, 0F3H, 03FH, 0F3H
DB 060H, 033H, 060H, 063H, 000H, 003H, 07FH, 0FFH, 07FH, 0FFH, 060H, 063H, 07FH, 0E3H, 07FH, 0E3H;"迎",2
DB 000H, 000H, 003H, 002H, 003H, 003H, 003H, 007H, 033H, 00EH, 03FH, 01CH, 00FH, 0F8H, 003H, 0F0H
DB 0FFH, 000H, 0FFH, 000H, 003H, 0FEH, 003H, 0FFH, 00FH, 003H, 03FH, 003H, 033H, 003H, 003H, 00FH;"光",3
DB 000H, 000H, 03FH, 0FCH, 03FH, 0FCH, 000H, 000H, 0FFH, 0FFH, 0FFH, 0FFH, 000H, 000H, 00CH, 000H
DB 01EH, 0FFH, 0F8H, 0FFH, 0F0H, 0C6H, 036H, 0FEH, 036H, 0FEH, 030H, 0C6H, 030H, 0FFH, 030H, 0FFH;"临",4

END

 

2012 07 10 更新  仍用汇编所用的上图

//16x16   2个138,2个595 控制LED点阵 流动显示 欢迎光临
//2012 07 10  E:\DPJ_C\点阵DIY\4X8X8\16X16_138595\16X16_138595.c

#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint  unsigned int
bit flag; 
sbit SH_CP=P2^0;
sbit DS=P2^1;
sbit ST_CP=P2^2;
sbit U2E1=P1^6;
sbit U3E1=P1^7; 
uchar code tab[ ]=    
{

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/

0x00,0x00,0x30,0x04,0x36,0x0E,0x37,0x3C,0x31,0xF0,0x3F,0xE0,0x3E,0x3A,0x00,0x13,
0x0E,0x07,0xFF,0x0E,0xF8,0x1C,0x1B,0xF8,0x1B,0xF0,0x18,0x1C,0x1E,0x0E,0x1E,0x07,/*"欢",1*/

0x00,0x00,0x03,0x02,0x73,0x07,0x73,0xFE,0x03,0xFC,0x00,0x06,0x3F,0xF3,0x3F,0xF3,
0x60,0x33,0x60,0x63,0x00,0x03,0x7F,0xFF,0x7F,0xFF,0x60,0x63,0x7F,0xE3,0x7F,0xE3,/*"迎",2*/

0x00,0x00,0x03,0x02,0x03,0x03,0x03,0x07,0x33,0x0E,0x3F,0x1C,0x0F,0xF8,0x03,0xF0,
0xFF,0x00,0xFF,0x00,0x03,0xFE,0x03,0xFF,0x0F,0x03,0x3F,0x03,0x33,0x03,0x03,0x0F,/*"光",3*/

0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x0C,0x00,
0x1E,0xFF,0xF8,0xFF,0xF0,0xC6,0x36,0xFE,0x36,0xFE,0x30,0xC6,0x30,0xFF,0x30,0xFF,/*"临",4*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",5*/

};

//顺向、逐列、阴码  黑体 字宽16 字高17   MATRIX-8X8-GREEN  左旋90度 左右翻转
//                MATRIX-8X8-RED    右旋90度 上下翻转
void delay_ms(unsigned int ms)
{
 uchar j;
 while(ms--)
 for(j=0;j<123;j++); 
}

void WriteByte(uchar dat)  

 uchar k;
 for(k=0;k<8;k++)
 {
  dat=dat>>1;
  DS=CY;
  SH_CP=0;
  SH_CP=1;
 }
}
void main()
{
 uchar num,temp,n,m,k;
 while(1)
 { P1=0;
  for(k=0;k<5;k++) //含空格,5个字符。
  for(n=0;n<16;n++)  //每字16行
     for(m=0;m<4;m++) //重复显示4次
  {
   for(num=n;num<16+n;num++)
    
   {
    WriteByte(tab[2*num+(k*32)+0]);
    WriteByte(tab[2*num+(k*32)+1]);
    ST_CP=0;
    ST_CP=1;
    if(flag==0)
    {
     P1=temp;
     U2E1=1;
     delay_ms(1);
     P1=0;  //关显示,消隐
     temp++;
    }
    else
    {
     P1=_crol_(temp,3);
     U3E1=1;
     delay_ms(1);
     P1=0; //关显示,消隐
     temp++;
    }
    delay_ms(1);
    if(temp==8)
    {
     flag=!flag;
     temp=0;
    }
   }
  }
 }
}

 

关于增加流动显示字数的补充    2012 10 31 更新

例子中为5 字符左流动,按程序中MOV R3,#80 ;R3存放的是总列数,亦即显示的总屏数。如果R3初为0则最大值256,可以显示16个字符。

但可再设一个R5,就可 16X16=256个数了。

 

比如上例中,显示“  欢迎光临”,如果再加上0~9及A~Z共41个字符,可以这样:

......

MAIN:
MOV R0,#8
MOV R4,#50;  
MOV DPTR,#TAB
MOV R3,#16  ;16列
MOV R5,#41  ;41个字符
MAIN1:

.....

INC DPTR
INC DPTR
DJNZ R5,MAIN1;这里加一条
MOV R5,#41
DJNZ R3,MAIN1 ;共显示16X41屏

AJMP MAIN;

WB:

......

同理,可再嵌套循环,显示的字数可以更多,只要单片机的ROM足够

阅读(1064) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册