欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
大神看看我這I2C總線程序編譯錯誤 怎么回事?
[打印本頁]
作者:
wps10025
時間:
2020-9-10 11:27
標題:
大神看看我這I2C總線程序編譯錯誤 怎么回事?
新手,學習I2C總線。
Build target 'Target 1'
compiling i2c總線學習.c...
I2C總線學習.C(18): warning C206: 'delay': missing function-prototype
I2C總線學習.C(51): error C231: 'delay': redefinition
I2C總線學習.C(51): error C231: 'delay': redefinition
Target not created
單片機源程序如下:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit sda=P2^0;
sbit scl=P2^1;
void delay1()
{
uint x,y;
for(x=5;x>0;x--)
for(y=5;y>0;y--);
}
void start()//起始信號
{
sda=1;
delay();
scl=1;
delay();
sda=0;
delay();
}
void stop()//終止信號
{
sda=0;
delay();
scl=1;
delay();
sda=1;
delay();
}
void response()//應答信號
{
uchar i;
scl=1;
delay();
while((sda==1)&&(i<250))
i++;
scl=0;
delay();
}
void delay()
{;;}
void init()//初始化
{
sda=1;
scl=1;
}
void wtite_byte(uchar date)
{
uchar i,temp;
temp=date;
scl=0;
delay();
for(i=0;i<8;i++)
{
temp=temp<<1;
sda=CY;
delay();
scl=1;
delay();
scl=0;
delay();
}
sda=1;
delay();
}
uchar read_byte()
{
uchar i,j,k;
scl=0;
delay();
scl=1;
delay();
for(i=0;i<8;i++)
{
scl=1;
delay();
j=sda;
k=(k<<1)|j;
scl=0;
delay();
}
return k;
}
void main()
{
init();
start();
write_byte(0xa0);
response();
write_byte(3);
response();
write_byte(0xfe);
response();
stop();
start();
write_byte(0xa0);
response();
write_byte(3);
response();
start();
write_byte(0xa1);
response();
P1=write_byte();
stop();
while(1);
}
作者:
wps10025
時間:
2020-9-10 11:28
說delay未定義,看不懂了,怎么沒定義
作者:
wps10025
時間:
2020-9-10 12:10
我找到錯誤地方了
是delay函數要放在最上邊,下面的函數可以調用。次序翻了,不能編譯。
也希望初學者以此為鑒。
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1