STM8 读取 SHT11有问题

2019-07-19 21:46发布

我用51能够读出来,但是到了STM8S103K3上面就一直有问题s_measure返回的错误值是2,然后就一直重连,请问这会是什么问题

[mw_shl_code=c,true] while (1) { error=0; error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP); //measure temperature if(error!=0) s_connectionreset(); //in case of an error: connection reset else { humi_val.f=(float)humi_val.i; //converts integer to float temp_val.f=(float)temp_val.i; //converts integer to float calc_sth11(&humi_val.f,&temp_val.f); //calculate humidity, temperature //dew_point=calc_dewpoint(humi_val.f,temp_val.f); //calculate dew point printf("temp:%5.1fC humi:%5.1f%% dewpoint:%5.1fC ",temp_val.f,humi_val.f,dew_point); } for (i=0;i<40000;i++); }[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。