MSP430单片机用12864液晶绘制DS18B20温度曲线源代码,keil4文件
单片机源程序如下:
- #include <msp430x14x.h>
- #include "Lcd12864.h"
- #include "DS18B20.h"
- #include "bmp.h"
- #define CPU_F ((double)8000000)
- #define delayus(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
- #define delayms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
- #define uchar unsigned char
- #define uint unsigned int
- //=========================================
- //函数功能:初始化时钟
- //=========================================
- void Init_CLK()
- {
- unsigned int i;
- WDTCTL = WDTPW + WDTHOLD; //停止看门狗
- BCSCTL1 &= ~XT2OFF; //打开XT2振荡器
- do
- {
- IFG1 &= ~OFIFG; //清除振荡器失效标志
- for(i = 0xff;i > 0;i--); //延时,等待XT2起振
- }
- while((IFG1 & OFIFG) != 0); //直到震荡失效标志不存在
- BCSCTL2 = SELM_2 + SELS; //选择MCLK、SMCLK为XT2
- }
- //=========================================
- //函数功能:主函数
- //=========================================
- void main()
- {
- uchar table[6];
- uint temp,XPonit,YPoint;
- float Point;
- Init_CLK();
- InitLcd12864();
- Init_DS18B20();
- FillGdram(0x00);
- DisplayBMP(bmp);
- while(1)
- {
- for(XPonit=8;XPonit<=127;XPonit++)
- {
- temp = Get_Temp();
- delayms(100);
- table[0] = temp / 100 + '0';
- table[1] = temp % 100 / 10 + '0';
- table[2] = '.';
- table[3] = temp % 10 + '0';
- table[4] = 'C';
- table[5] = '\0';
- DisplayString(1,6,table); //显示第一行,从第1个位置开始
- Point = (float)temp / 10 + 0.5;
- YPoint = 63 - ((int)Point + 7);
- DrawPoint(XPonit,YPoint,1);
- }
- if(XPonit == 128)
- {
- XPonit = 8;
- FillGdram(0x00);
- DisplayBMP(bmp);
- }
- }
- /*
- //DrawPoint(7,7,1); // 画点(7,7)
- // 8 x 8 表格程序段开始
-
- DrawHorizontalLine(0,127,0,1);
-
-
- DrawHorizontalLine(0,127,15,1);
- DrawHorizontalLine(0,127,23,1);
- DrawHorizontalLine(0,127,31,1);
- DrawHorizontalLine(0,127,39,1);
- DrawHorizontalLine(0,127,47,1);
- DrawHorizontalLine(0,127,55,1);
- DrawHorizontalLine(0,127,63,1);
- DrawVerticalLine(0,0,63,1);
- DrawVerticalLine(15,0,63,1);
- DrawVerticalLine(31,0,63,1);
- DrawVerticalLine(47,0,63,1);
- DrawVerticalLine(63,0,63,1);
- DrawVerticalLine(79,0,63,1);
- DrawVerticalLine(95,0,63,1);
- DrawVerticalLine(111,0,63,1);
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
MSP430单片机用12864液晶绘制DS18B20温度曲线源代码.rar
(62.2 KB, 下载次数: 32)
|