weixin_57418095
2022-06-03 14:15
采纳率: 66.7%
浏览 195

keil5出现illegal type conversion from/to 'void'错误怎么处理(关键词-main)

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;

}
}

3条回答 默认 最新

相关推荐 更多相似问题