- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- 404分 北大法硕考研心得(404 North Fashuo postgraduate experience).doc
- 3韩非子(3 Han Feizi).doc
- 40句浪漫的英文句子(40 sentences in romantic English).doc
- 3管晏列传翻译(3 Guan Yan biography translation).doc
- 40段经典笑话 让你哭笑不得~(40 classic jokes make you laugh or cry!).doc
- 3智力竞赛3(3 quiz 3).doc
- 4.4推荐作品(4.4 recommended works).doc
- 40种方法教你如何做鸡(40 ways to teach you how to cook chicken).doc
- 41-望山楚简「述瘥」考释(41- from the mountain bamboo slips in).doc
- 41古代名人故事四则(41 ancient celebrity stories four).doc
文档评论(0)