2019-08-18 18:46发布
yzn327 发表于 2017-4-17 11:16 请问问题解决了吗?我用F1的例程改了芯片改了引脚,初始化能通过,可读取回来的温度也全是0,但是换F4的板 ...
ken123 发表于 2017-5-13 23:20 有STM8的18b20的?
最多设置5个标签!
u8 t=0;
short temperature;
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
while(DS18B20_Init());
while(1)
{
if(t%10==0)//每100ms读取一次
{
temperature=DS18B20_Get_Temp();
if(temperature<0)
{
//LCD_ShowChar(60+40,150,'-',16,0); //显示负号
temperature=-temperature; //转为正数
}
//else LCD_ShowChar(60+40,150,' ',16,0); //去掉负号
//LCD_ShowNum(60+40+8,150,temperature/10,2,16); //显示正数部分
//LCD_ShowNum(60+40+32,150,temperature%10,1,16); //显示小数部分
printf("temperature=%f ",temperature/10.0);
}
delay_ms(10);
t++;
if(t==20)
{
t=0;
LED0=!LED0;
}
}
解决了,要不要发给你
有的话请您发过来,论坛、邮箱都可以,QQ邮箱978322461@qq.com,不是抄袭,这是借鉴您的设计思想
一周热门 更多>