#include<reg52.h>
//
#define uchar unsigned char
#define uint unsigned int
//
sbit scd=P1^0;
sbit SRCLK=P1^1;
sbit SER=P1^2;
//公共端
sbit RCLKZ=P2^0;
sbit SRCLKZ=P2^1;
sbit SERZ=P2^2;
void delay(uint z);
uchar code tab[]={0x00,0x6C,0x92,0x82,0x44,0x28,0x10,0x01,0x6C};
uchar segout[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
//发送一个字节
void SendByte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
SRCLK=0;
SER=dat&&0x80;
dat<<=1;
SRCLK=1;
}
}
//发送两个字节(点阵有两种颜色,每一种数据控制一个颜色,HC595级联,一共两块,N个发送个字节)
void SendByte2(uchar dat1,uchar dat2)
{
SendByte(dat1);
SendByte(dat2);
}
//发送数据后进行锁存输出
void out(void)
{
scd=0; //锁存端
delay(12);
scd=1;
}
//发送位码,用另外一块HC595 ,公共端 锁存输出
void sendweima(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
SRCLKZ=0;
SERZ=dat&0x80;
dat<<=1;
SRCLKZ=1;
}
RCLKZ=0;//锁存
delay(12);
RCLKZ=1;
}
void delay(uint z)
{
uint x;
uchar y;
for(x=z;x>0;x--)
for(y=20;y>0;y--);
}
//主程序
void main()
{ uchar i;
while(1)
{
for(i=0;i<8;i++)
{
SendByte(segout[i]);//发送一个字节
SendByte2(~tab[i],0xff);//发送两个字节
out();//输出
delay(12);
SendByte2(0xff,0xff);//全部不显示,防止重影
out();
}
}
}
为什么显示*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_SENDWEIMA?_阏?
Program Size: data=18.0 xdata=0 code=307
错误在哪里啊。。。 |