基于MSP430G2553的DS18B20测温程序

上传人:mg****2 文档编号:123503028 上传时间:2020-03-09 格式:DOC 页数:15 大小:61KB
返回 下载 相关 举报
基于MSP430G2553的DS18B20测温程序_第1页
第1页 / 共15页
基于MSP430G2553的DS18B20测温程序_第2页
第2页 / 共15页
基于MSP430G2553的DS18B20测温程序_第3页
第3页 / 共15页
基于MSP430G2553的DS18B20测温程序_第4页
第4页 / 共15页
基于MSP430G2553的DS18B20测温程序_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《基于MSP430G2553的DS18B20测温程序》由会员分享,可在线阅读,更多相关《基于MSP430G2553的DS18B20测温程序(15页珍藏版)》请在金锄头文库上搜索。

1、./* * main.c */*include header file*/#include #include system.h#include uart.h#include ds18b20.hunsigned int temp;char tx_buf6 = 0,0,0,0,n,0;/* Function name: main* Descriptions: main function* input parameters: none* output parameters: none* Returned value:none*/void main(void)System_Init();UartIni

2、t();_EINT();if (DS18B20_Init()P1OUT |= BIT0;elseP1OUT |= BIT6;while (1)_delay_cycles(800000);_delay_cycles(800000);temp = DS18B20_GetTemp();/x_buf0 = temp%10000/1000+0;/tx_buf1 = temp%1000/100+0;/tx_buf2 = temp%100/10+0;/tx_buf3 = temp%10+0;tx_buf0 = temp%100/10+0;tx_buf1 = temp%10+0;Uart_SendStr(tx

3、_buf);/*Include header file*/#include #include system.h/*Function Declaration*/void Config_WDT(void);void Config_Clock(void);void Config_IO(void);/* Function name: Config_WDT* Descriptions: WatchDog Timer Configuration* input parameters: none* output parameters: none* Returned value: none*/void Conf

4、ig_WDT(void)WDTCTL = WDTPW + WDTHOLD; / Stop watchdog timer/* Function name: Config_Clock* Descriptions: System Clock Configuration* input parameters: none* output parameters: none* Returned value: none*/void Config_Clock(void)BCSCTL1 = CALBC1_8MHZ;/ Set DCO 1M 8M 12M 16MDCOCTL = CALDCO_8MHZ;BCSCTL2

5、 = SELM_1 + DIVM_1 + DIVS_3;/ MCLK = 8M;SMCLK = 1MBCSCTL2 &= SELS;if (CALBC1_8MHZ = 0xFF | CALDCO_8MHZ = 0xFF)while(1);/hang-up/* Function name: Config_IO* Descriptions: IO Port Configuration* input parameters: none* output parameters: none* Returned value: none*/void Config_IO(void)/ set all IO por

6、t outputsP1DIR = 0xFF; / All P1.x outputsP1OUT = 0x00; / All P1.x resetP2DIR = 0xFF; / All P2.x outputsP2OUT = 0x00; / All P2.x reset/* Function name: System_Init* Descriptions: WatchDog Timer Configuration* input parameters: none* output parameters: none* Returned value: none*/void System_Init(void)Config_WDT();Config_Clock();Config_IO();_delay_cycles(800000);_delay_cycles(800000);#ifndef SYSTEM_H_#define SYSTEM_H_/*Extern Function Declaration*/extern void System_Init(void);#endif /* SYSTEM_H_ */*/#include #include #include uart.h/* Function name: UartInit* Descriptions:

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 设计及方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号