Objects\main.c(13): error C193: '=': illegal type conversion from/to 'void'
void main()
{
LCD_Init();
DS1302_Init();
LCD_ShowString(1,1,"RTC");
DS1302_WriteByte(0x80,0x03);
Second=DS1302_ReadByte(0x81);//错误在这一行
LCD_Showkey(2,1,Second,3);
while(1)
{}
unsigned char DS1302_ReadByte(unsigned char Command)
{
unsigned char i,Data=0x00;
DS1302_RST=1;
for(i=0;i<8;i++)
{
DS1302_IO=Command&(0x01<<i);
DS1302_SCLK=0;
DS1302_SCLK=1;
}
for(i=0;i<8;i++)
{
DS1302_SCLK=1;
DS1302_SCLK=0;
if(DS1302_IO){Data|=(0x01<<i);}
}
DS1302_RST=0;
DS1302_IO=0; //读取后将IO设置为0,否则读出的数据会出错
return Data;
}
}
Second
怎么定义的?
我已经找到问题所在了,是因为我在DS1302_readbyte.h文件中用void来定义的,导致报错,感谢回答问题的人
DS1302_ReadByte这个函数在调用之前没有声明,编译器会自动把它作为空类型处理。
在main前面加一句unsigned char DS1302_ReadByte(unsigned char Command);做个声明,或者把main函数写到DS1302_ReadByte后面。
Second的定义位置也要确认一下。