标题:
16*32LED点阵屏左移的程序请大神指教
[打印本页]
作者:
zcwjzwd
时间:
2019-6-5 22:31
标题:
16*32LED点阵屏左移的程序请大神指教
最近抄了一个LED点阵屏左移的程序16*32,用的138和595,可是在定义字模数组的时候只能定义5个字,多于5个字就没有显示,五个字以内就正常,请
大神们给予指点,
以下是源程序
#include<STC12C5A60S2.h>
#include <intrins.h>
typedef unsigned char uchar;
typedef unsigned int uint;
sbit SDA_G =P4^1; //
sbit SDA_R =P4^5;//串行数据输入
sbit SHCP =P0^6; //移位时钟脉冲
sbit STCP =P4^6; //输出锁存器控制脉冲
sbit IA=P2^0;//
sbit IB=P2^1; //
sbit IC=P2^2; //
sbit ID=P2^3;//
sbit OE=P4^4; //
//uint uiAllData;
uchar Move,line,Speed;
uint zimuo;
uchar BUFF[20]; //缓存
void DelayMs(void); // 延时
void in_data(); // 调整移动数据
void rxd_data(); // 发送移动数据
uchar code hanzi[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x01,0x00,0x01,0x3F,0x01,0x20,0x3F,0xA0,0x20,0x92,0x10,0x54,0x02,0x28,0x02,
0x08,0x02,0x14,0x05,0x24,0x05,0xA2,0x08,0x81,0x08,0x40,0x10,0x20,0x20,0x10,0x40,/*"欢",0*/
0x00,0x00,0x04,0x01,0xC8,0x3C,0x48,0x24,0x40,0x24,0x40,0x24,0x4F,0x24,0x48,0x24,
0x48,0x24,0x48,0x2D,0xC8,0x14,0x48,0x04,0x08,0x04,0x14,0x04,0xE2,0x7F,0x00,0x00,/*"迎",1*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/
};
/******************************************************/
/*****不影响其他端口的扫描*************************/
void scan(uchar Value)
{
switch(Value)
{case 0: {IA=0;IB=0;IC=0;ID=0;};break;
case 1:{IA=1;IB=0;IC=0;ID=0;};break;
case 2:{IA=0;IB=1;IC=0;ID=0;};break;
case 3: {IA=1;IB=1;IC=0;ID=0;};break;
case 4: {IA=0;IB=0;IC=1;ID=0;};break;
case 5: {IA=1;IB=0;IC=1;ID=0;};break;
case 6: {IA=0;IB=1;IC=1;ID=0;};break;
case 7:{IA=1;IB=1;IC=1;ID=0;};break;
case 8: {IA=0;IB=0;IC=0;ID=1;};break;
case 9: {IA=1;IB=0;IC=0;ID=1;};break;
case 10:{IA=0;IB=1;IC=0;ID=1;};break;
case 11: {IA=1;IB=1;IC=0;ID=1;};break;
case 12: {IA=0;IB=0;IC=1;ID=1;};break;
case 13:{IA=1;IB=0;IC=1;ID=1;};break;
case 14:{IA=0;IB=1;IC=1;ID=1;};break;
case 15:{IA=1;IB=1;IC=1;ID=1;};break;
default:break;
}
}
/**************************延时***********************/
void DelayMs(void)
{
unsigned char i, j;
_nop_();
i = 11;
j = 190;
do
{
while (--j);
} while (--i);
}
void Timer0Init(void) //1毫秒@22.1184MHz
{
AUXR &= 0x7F; //定时器时钟12T模式
TMOD &= 0xF0; //设置定时器模式
TMOD |= 0x01; //设置定时器模式
TL0 = 0xCD; //设置定时初值
TH0 = 0xF8; //设置定时初值
TR0 = 1; //定时器0开始计时
EA=1;
ET0=1;
}
/********************************************/
/*主函数*/
void main()
{ P4SW=0x70;
P2M1=0x00;P2M0=0x0f;
P4M1=0x00;P4M0=0xff;
P3M1=0x00;P3M0=0x80;
zimuo=0;
Move=0;
SHCP=0;
STCP=0;
Timer0Init();
line=0;
while(1)
{
while(zimuo<128)
{
while(Move<16)
{
for(Speed=0;Speed<15;Speed++)
{
for(line=0;line<16;line++)
{
in_data(); //
rxd_data(); //
scan(line); //
OE=1;//
DelayMs();
OE=0;
}
}
Move++;
}
Move=0;
zimuo=zimuo+32;
}
zimuo=0;
}
}
/******************************************************** */
void in_data(void)
{
uchar s;
for(s=0;s<8;s++)
{
BUFF[2*s]=hanzi[zimuo+32*s+2*line];
BUFF[2*s+1]=hanzi[zimuo+1+32*s+2*line];
}
}
/***********************发送移动的数据************************ */
void rxd_data(void)
{
uchar h;
uchar inc,tempyid,temp,k;
if(Move<8)
inc=0;
else
inc=1;
for(h=0+inc;h<4+inc;h++)
{
if(Move<8)
tempyid=Move;
else
tempyid=Move-8;
temp=(BUFF[h]>>tempyid)|(BUFF[h+1]<<(8-tempyid));
temp=~temp;
for(k=0;k<8;k++)
{
SHCP=0;
if(temp&0x01==0x01)
{
SDA_G=1;
}
else
{
SDA_G=0;
}
// SDA_G=(bit)(temp&0x01);
temp=temp>>1;
SHCP=1;
_nop_();
_nop_();
}
STCP=1;
STCP=0;
}
}
复制代码
作者:
ssk7793
时间:
2019-6-6 11:05
看我发的贴,有仿真和程序有备注。
作者:
zhangxiaoljs
时间:
2020-1-17 22:33
while(zimuo<128)//128除32=4,修改128
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1