DS18B20时序分析和总结.docxVIP

  • 5
  • 0
  • 约9.55千字
  • 约 11页
  • 2023-03-09 发布于湖北
  • 举报
DS18B20 时序 Author:exploer CIEE ,CAU 2008-9-16 本文档参照 Maxim 公司 DS18B20 的 Datasheet 而完成。其中,加了 灰框的部分为原文档内容,其中英文部分为官方文档内容,中文部分为本人的翻译。限于本人水平,本文档可能存在错误或者让人误解的内容,对于因此引起的一切问题作者(exploer,CIEE-CAU)概不负责。 INITIALIZATION PROCEDURE—RESET AND PRESENCE PULSES 初始化序列——复位和存在脉冲 All communication with the DS18B20 begins with an initializati on sequence that consists of a reset pulse from the master follo wed by a presence pulse from the DS18B20. This is illustrated in Figure 13. When the DS18B20 sends the presence pulse in resp onse to the reset, it is indicating to the master that it is on the bus and ready to operate. DS18B20 的所有通信都由由复位脉冲组成的初始化序列开始。该初始化序 列由主机发出,后跟由 DS18B20 发出的存在脉冲(presence pulse)。下图 (插图 13,即如下截图)阐述了这一点。当发出应答复位脉冲的存在脉冲后, DS18B20 通知主机它在总线上并且准备好操作了。 During the initialization sequence the bus master transmits (T X) 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 re ceive mode (RX). 在初始化步骤中,总线上的主机通过拉低单总线至少 480μs 来产生复位脉冲。然后总线主机释放总线并进入接收模式。 When the bus is released, the 5kΩ pullup resistor pulls the 1- Wire bus high. When the DS18B20 detects this rising edge, it wa its 15μs to 60μs and then transmits a presence pulse by pulling t he 1-Wire bus low for 60μs to 240μs. 当总线释放后,5kΩ 的上拉电阻把单总线上的电平拉回高电平。当 DS18B 20 检测到上升沿后等待 15 到 60us,然后以拉低总线 60-240us 的方式发出 存在脉冲。 如文档所述,主机将总线拉低最短 480us,之后释放总线。由于 5kΩ 上拉电阻的作用,总线恢复到高电平。DS18B20 检测到上升沿后等待 15 到 60us, 发出存在脉冲:拉低总线 60-240us。至此,初始化和存在时序完毕。 根据上述要求编写的复位函数为: 首先是延时函数:(由于 DS18B20 延时均以 15us 为单位,故编写了延时单位为 15us 的延时函数,注意:以下延时函数晶振为 12MHz) /* ************************************ 函数:Delayxus_DS18B20 功能:DS18B20 延时函数参数:t 为定时时间长度 返回:无 说明: 延时公式:15n+15 (近似),晶振 12Mhz ****************************************** */ void Delayxus_DS18B20(unsigned int t) { for(t;t0;t--) { _nop_();_nop_();_nop_();_nop_(); } _nop_(); _nop_(); } 延时函数反汇编代码(方便分析延时公式) C:0x0031 7F01 MOV R7,#0x01 C:0x0033 7E00 MOV R6,#0x00 C:0x0035 1206A6 LCALL delayxus(C:06A6) 38: void Delayxus_DS18B20(unsigned int t) 39: { 40: f

文档评论(0)

1亿VIP精品文档

相关文档