LZ最好多看看c语言基础的书。。。
1,所有的变量都要先定义再使用;
2,位地址scl, sda 也要先定义,再使用;
3,该包含的头文件要包含;
4,子程序要有定义和声明,才能调用;
以下为改过的,可以编译通过,但有警告。
#include "reg52.h"
#define uchar unsigned char
sbit scl=P2^0;
sbit sda=P2^1;
void write_byte24c02(uchar date) //写字节
{
uchar sj=0;
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay();
sda=CY;
delay();
scl=1;
delay();
}
scl=0;
delay();
sda=1;
delay();
sj=1;
}
uchar read_byte24c02() //读字节
{
uchar sj=0;
uchar j,l;
scl=0;
delay();
sda=1;
delay();
for(j=0;j<8;j++)
{
scl=1;
delay();
l=(l<<1)|sda;
scl=0;
delay();
}
return l;
sj=1;
}
|