MSP430單片機用12864液晶繪制DS18B20溫度曲線源代碼,keil4文件
0.png (56.05 KB, 下載次數: 136)
下載附件
2017-7-11 21:34 上傳
單片機源程序如下:
- #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)
2017-7-11 19:16 上傳
點擊文件名下載附件
5 下載積分: 黑幣 -5
|