两个74hc595级联第一个怎么不可以的?
#include<reg51.h>#include<intrins.h>#defineuintunsignedint#defineucharunsignedchar#de...
#include <reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define num 3
#define row P3
sbit si=P2^1;
sbit sck=P2^0;
sbit rck=P3^6;
sbit sclr=P3^5;
sbit G=P3^7;
void col(uint s,uint r);
void out();
uchar code screen[3][32]=
{
{0xf7,0xdf,0xf9,0xcf,0xfb,0xbf,0xc0,0x07
,0xde,0xf7,0xc0,0x07,0xde,0xf7,0xde,0xf7
,0xc0,0x07,0xde,0xf7,0xfe,0xff,0x00,0x01
,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff}, //单
{0xff,0xbf,0xef,0xbf,0xef,0xbf,0xef,0xbb
,0xe0,0x01,0xef,0xff,0xef,0xff,0xef,0xff
,0xef,0xe0,0x0f,0xef,0xef,0xef,0xef,0xef
,0xdf,0xef,0xdf,0xef,0xbf,0xef,0x7f,0xef}, //片
{0xef,0xff,0xef,0x07,0xef,0x77,0x01,0x77
,0xef,0x77,0xef,0x77,0xc7,0x77,0xcb,0x77
,0xab,0x77,0xaf,0x77,0x6e,0xf7,0xee,0xf5
,0xed,0xf5,0xed,0xf5,0xeb,0xf9,0xef,0xff}, //机
};
void main()
{
uint i,j,k;
uchar rsel;//定义行选码变量
while (1)
{
for(i=0;i<3;i++)
for(j=0;j<10000;j++)
for(k=0;k<16;k++)
{
col(i,k);
G=1; //关595 (使能端)
out(); //
P3=(0xf0+k);
G=0; //开595
}
}
}
void out()
{
rck=0;
_nop_(); //输出存储器锁存移位寄存器中的状态值(上升沿)
_nop_(); // 这个函数是延时一个机器周期的意思
rck=1 ;
//输出存储状态保持(下降沿)
}
void col(uint s ,uint r)
{
uchar i, datal,k;
for(k=0;k<=1;k++)
{
if(k==0)
datal=screen[s][2*r];
for(i=0;i<8;i++)
{
sck=0; //上升沿
if((datal&0x80)==0x80)
si=1; //移位寄存器存储高位 ( sck上升沿)
else
si=0; //移位寄存器存储低位 ( sck上升沿)
datal<<=1;
sck=1;
//下降沿 (移位寄存器状态保持)
} if(k==1)
datal=screen[s][2*r+1];
}
} 展开
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define num 3
#define row P3
sbit si=P2^1;
sbit sck=P2^0;
sbit rck=P3^6;
sbit sclr=P3^5;
sbit G=P3^7;
void col(uint s,uint r);
void out();
uchar code screen[3][32]=
{
{0xf7,0xdf,0xf9,0xcf,0xfb,0xbf,0xc0,0x07
,0xde,0xf7,0xc0,0x07,0xde,0xf7,0xde,0xf7
,0xc0,0x07,0xde,0xf7,0xfe,0xff,0x00,0x01
,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff}, //单
{0xff,0xbf,0xef,0xbf,0xef,0xbf,0xef,0xbb
,0xe0,0x01,0xef,0xff,0xef,0xff,0xef,0xff
,0xef,0xe0,0x0f,0xef,0xef,0xef,0xef,0xef
,0xdf,0xef,0xdf,0xef,0xbf,0xef,0x7f,0xef}, //片
{0xef,0xff,0xef,0x07,0xef,0x77,0x01,0x77
,0xef,0x77,0xef,0x77,0xc7,0x77,0xcb,0x77
,0xab,0x77,0xaf,0x77,0x6e,0xf7,0xee,0xf5
,0xed,0xf5,0xed,0xf5,0xeb,0xf9,0xef,0xff}, //机
};
void main()
{
uint i,j,k;
uchar rsel;//定义行选码变量
while (1)
{
for(i=0;i<3;i++)
for(j=0;j<10000;j++)
for(k=0;k<16;k++)
{
col(i,k);
G=1; //关595 (使能端)
out(); //
P3=(0xf0+k);
G=0; //开595
}
}
}
void out()
{
rck=0;
_nop_(); //输出存储器锁存移位寄存器中的状态值(上升沿)
_nop_(); // 这个函数是延时一个机器周期的意思
rck=1 ;
//输出存储状态保持(下降沿)
}
void col(uint s ,uint r)
{
uchar i, datal,k;
for(k=0;k<=1;k++)
{
if(k==0)
datal=screen[s][2*r];
for(i=0;i<8;i++)
{
sck=0; //上升沿
if((datal&0x80)==0x80)
si=1; //移位寄存器存储高位 ( sck上升沿)
else
si=0; //移位寄存器存储低位 ( sck上升沿)
datal<<=1;
sck=1;
//下降沿 (移位寄存器状态保持)
} if(k==1)
datal=screen[s][2*r+1];
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询