普中科技的开发板,用74H595控制8*8 led 点阵显示爱心,调试总是失败,点阵全部点亮。代码如下,内附原理图。请求大佬们帮助。
#include <reg51.h>
#include <intrins.h>
#define u8 unsigned char
#define u16 unsigned int
sbit SER=P3^4;
sbit RCLK=P3^5;
sbit SRCLK=P3^6;
u8 ledduan[]={0x38,0x44,0x42,0x21,
0x42,0x44,0x38,0x00};
u8 ledwei[]={0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe};
void delay(u8 i)
{
while(i--);
}
void sendByte(u8 dat)
{
u8 i;
SRCLK=0;
RCLK=0;
for(i=0;i<8;i++)
{
SRCLK=1;
SER=dat>>7;
dat<<=1;
_nop_();
_nop_();
SRCLK=0;
}
RCLK=1;
_nop_();
_nop_();
RCLK=0;
}
void main()
{
u8 i;
while(1)
{
P0=0x7f;
for(i=0;i<8;i++)
{
P0=ledwei[i];
sendByte(ledduan[i]);
delay(100);
}
}
}
|