41..STM32F469I----DS18B20温度采集+串口发送
STMCU
2876 人阅读
|
0 人回复
|
2018-01-12
TA的每日心情 | 难过 2021-2-27 22:16 |
|---|
签到天数: 1568 天 连续签到: 1 天 [LV.Master]伴坛终老
司徒
- 积分
- 33047
|
【STM32F469I试用】+DS18B20温度采集+串口发送 【转】
利用CubeMX实现了DS18B20温度采集,分享一下实现过程和程序。
1.在CubeMX中新建项目,选择Board selector->STM32F469I-DISCO
2.配置DS18B20数据IO口为PB1,并配置串口USART6,用于输出结果
USART6参数配置如下:
3.时钟配置如下,系统时钟为90MHz
4.生成KEIL Project
5.在main.c中加入如下代码,读取DS18B20温度数据
DS18B20子函数如下:
其中的us延时函数用while()循环实现:
void delay_us(uint32_t value)
{
uint32_t i;
i = value * 21;
while(i--);
}6.串口重定向实现如下:
int fputc(int ch, FILE *f)
{
/* Place your implementation of fputc here */
/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
HAL_UART_Transmit(&huart6, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
7.硬件接线及运行结果如下:
附程序:
|
|
|
|
|
|
|
|
|