ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

DS18B10 (Programmable Resolution 1-Wire Digital Thermometer 可编程分辨率1线数字温度计)驱动理解

2021-03-31 18:57:21  阅读:260  来源: 互联网

标签:初始化 Wire DS18B20 bus DS18B10 pulse Digital DQ


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不同型号的管脚排列:

PIN CONFIGURATIONS
这里看到(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.

在这里插入图片描述

标签:初始化,Wire,DS18B20,bus,DS18B10,pulse,Digital,DQ
来源: https://blog.csdn.net/qq_43613400/article/details/115356655

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有