DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1577字,纯文字阅读大概需要3分钟。
内容图文
![DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解](/upload/InfoBanner/zyjiaocheng/596/7a53107cab2141508b98d9e85fad3bc5.jpg)
DS18B20驱动程序探索
前言
本文通过理解DS18B20的驱动程序,更好的理解DS18B20的功能,其中驱动程序为蓝桥杯官方提供的驱动,解释则通过摘录芯片手册中的内容。
DS18B20初始化方法
下面展示一些 内联代码片
。
#include "reg52.h"
sbit DQ = P1^4; // 单总线接口:单片机的P1.4端连接在DS18B20的DQ端
// DS18B20设备初始化
bit init_ds18b20(void)
{
bit initflag = 0;
DQ = 1;
Delay_OneWire(12);
DQ = 0;
Delay_OneWire(80);
DQ = 1;
Delay_OneWire(10);
initflag = DQ;
Delay_OneWire(5);
return initflag;
}
1. DQ为何物?
下图是DS1802不同型号的管脚排列:
这里看到(DS18B20)的管脚图,由接地端GND,电源端VDD,和数字信号输入/输出端DQ三个端口组成。下面是芯片手册中的解释:
2. DS18B20设备初始化流程:
//芯片手册的描述
INITIALIZATION PROCEDURE—RESET AND PRESENCE PULSES
All communication with the DS18B20 begins with an initialization sequence that consists of a reset pulse
from the master followed by a presence pulse from the DS18B20. This is illustrated in Figure 13. When
the DS18B20 sends the presence pulse in response to the reset, it is indicating to the master that it is on
the bus and ready to operate.
During the initialization sequence the bus master transmits (TX) the reset pulse by pulling the 1-Wire bus
low for a minimum of 480μs. The bus master then releases the bus and goes into receive mode (RX).
When the bus is released, the 5k? pullup resistor pulls the 1-Wire bus high. When the DS18B20 detects
this rising edge, it waits 15μs to 60μs and then transmits a presence pulse by pulling the 1-Wire bus low
for 60μs to 240μs.
内容总结
以上是互联网集市为您收集整理的DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解全部内容,希望文章能够帮你解决DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。