ds18b20寄生供电模式(c程序)(DS18B20 parasitic power supply mode (C program)).doc

ds18b20寄生供电模式(c程序)(DS18B20 parasitic power supply mode (C program)).doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ds18b20寄生供电模式(c程序)(DS18B20 parasitic power supply mode (C program))

ds18b20寄生供电模式(c程序)(DS18B20 parasitic power supply mode (C program)) The //*************DS18B20 program began *******************/ parasitic power supply mode / / data port P3.6, strong pull port P3.7 system clock 3.2768MHz //*******************************************************/ #include msp430xG46x.h #define uint unsigned int #define uchar unsigned char Uchar, BIT_Array[8]={BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7}; Uchar flag; / / judge reset success Uchar SUNX; / / temperature value The sub function *********************/ //****************** statement quoted Uchar Read_DQ (uchar Num); / / set the IO port for input mode Void Set_DQ (uchar num, uchar DAT); / / set the IO port for output mode Void delay (uint count); / / delay function Uchar ReadOneChar (void); / / read a byte Void WriteOneChar (uchar DAT); / / write a byte Void Init_DS18B20 (void); / / reset Void tmpchange (void); / / convert temperature Uchar ReadTemperature (void); / / read the temperature value //**************** start DS18B20 temperature conversion ****************/ Void tmpchange (void) { Init_DS18B20 (); If (flag==1) to determine whether success / reset { Delay (1); WriteOneChar (0xCC); / / read serial number column number operation skip WriteOneChar (0x44); / / convert temperature Set_DQ (7,0); / / strong pull to P3.7 } } //******************** temperature readings from the 18B20 value of ******************/ / / P3.6 was defined as DQ. DQ represents the IO port that is connected to the 18b20; Uchar ReadTemperature (void) { Uchar aa=0; Uchar bb=0; Uint t=0; Uint tt=0; Set_DQ (7,1); / / strong pull off P3.7 Init_DS18B20 (); Delay (5); If (flag==1) to determine whether success / reset { Delay (1); WriteOneChar (0xCC); / / read serial number column number operation skip WriteOneChar (0xBE); / / read the temperature register (a total of 9 readable registers) before two is the temperature Aa=ReadOneChar (); Bb=ReadOneChar (); Init_DS18B20 (); Delay (5); T=bb; T=8; T=t|aa; Tt=t*0.0625; Ret

文档评论(0)

jgx3536 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档