你的程序正确才怪!!!!!
第一:编译有错:RCLK没申明。所以没能编译出可执行文件.HEX,你真的下载起了?那么就不是这个程序,当然不会显示正确了。
第二:主函数都没有,还说“函数正确”
不知道是不是你没有发全部程序。显示0的程序我也有一个,看看吧。
#include<reg51.h>
#include<intrins.h>
sbit SRCLK=P3^6;
sbit RCLK=P3^5;
sbit SER=P3^4;
unsigned char code TAB[8] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
unsigned char code CHARCODE[20][8]=
{
{0x00,0x00,0x00,0x3E,0x41,0x41,0x41,0x3E}, //0
{0x00,0x00,0x00,0x00,0x21,0x7F,0x01,0x00}, //1
{0x00,0x00,0x00,0x21,0x43,0x45,0x49,0x31}, //2
{0x00,0x00,0x00,0x42,0x41,0x51,0x69,0x46}, //3
{0x00,0x00,0x00,0x0C,0x14,0x24,0x7F,0x04}, //4
{0x00,0x00,0x00,0x72,0x51,0x51,0x51,0x4E}, //5
{0x00,0x00,0x00,0x1E,0x29,0x49,0x49,0x06}, //6
{0x00,0x00,0x00,0x40,0x40,0x4F,0x50,0x60}, //7
{0x00,0x00,0x00,0x36,0x49,0x49,0x49,0x36}, //8
{0x00,0x00,0x00,0x30,0x49,0x49,0x4A,0x3C}, //9
{0x00,0x00,0x01,0x1F,0xE4,0x3C,0x07,0x01}, //A
{0x00,0x00,0x00,0x81,0xFF,0x91,0x91,0x6e}, //B
{0x00,0x00,0x00,0x7E,0x81,0x81,0x81,0xc2}, //C
{0x00,0x00,0x00,0x81,0xFF,0x81,0x81,0x7e}, //D
{0x00,0x00,0x00,0x81,0xFF,0x91,0xb9,0xc3}, //E
{0x00,0x00,0x00,0x81,0xFF,0x91,0xb8,0xc0}, //F
{0x00,0x00,0x3C,0x42,0x81,0x89,0xce,0x08}, //G
{0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00}, //中
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //全灭
{0x3C,0x62,0xB1,0xAB,0x87,0xB1,0x62,0x3C}//人脸
};
void delay(unsigned int time)//0.0001766s延时,约0.2ms
{
unsigned int j;
for(time;time>0;time--)
for(j=0;j<20;j++);
}
void Hc595SendByte(unsigned char dat)
{
unsigned char a;
SRCLK=0;
RCLK=0;
for(a=0;a<8;a++)
{
if ((dat<<a)&0x80)
{
SER=1;
}
else
{
SER=0;
}
SRCLK=1;
_nop_();
_nop_();
SRCLK=0;
}
RCLK=1;
_nop_();
_nop_();
RCLK=0;
}
void main ()
{
unsigned char i,j,k;
P0=0xff;
while (1)
{
for (i=0;i<20;i++)
{
for (j=0;j<100;j++)
{
for (k=0;k<8;k++)
{
P0=0xff;
Hc595SendByte(CHARCODE[i][k]);
P0=TAB[k];
delay(5);
}
}
}
}
}
|