欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
MSP430單片機的實時時鐘及溫度顯示程序
[打印本頁]
作者:
飛機翻筋斗
時間:
2019-4-14 09:23
標題:
MSP430單片機的實時時鐘及溫度顯示程序
最近學習MSP430,把以前學習的DS1302和DB18B20移植過來了,把時序搞清楚還是比較簡單的,溫度顯示做得比較粗糙,分享一下(PS:后續有時間添加按鍵設置及其他功能
)
da3ea7c4adeb0d689b75910cf2d828e.jpg
(6.03 MB, 下載次數: 81)
下載附件
2019-4-14 09:23 上傳
單片機源程序如下:
#include<msp430x14x.h>
#include"lcd1602.c"
#include"ds1302.c"
#include"ds18b20.c"
//typedef unsigned char uchar;
//typedef unsigned int uint;
//uchar str1[]="hongchao12345678";
//uchar str2[]="hongchao12345678";
//uchar LcdMove[16+sizeof(str1)+16];
uchar index=0,T500MSfg=0,flash=0;
uchar psec=0xaa;
uchar time[8],str[12];
//uchar second=10,minute=20,hour=11;
/*
void Lcd_Move()
{
uchar i;
for(i=0;i<16;i++)
{
LcdMove[i]=' ';
}
for(i=0;i<sizeof(str1);i++)
{
LcdMove[16+i]=str1[i];
}
for(i=16+sizeof(str1);i<sizeof(LcdMove);i++)
{
LcdMove[i]=' ';
}
}
*/
void Time0_Init()
{
TACTL=TASSEL_1+ ID_3+ MC_1;
CCTL0=CCIE;
CCR0=1024;
}
/*
void clock()
{
second++;
if(second>59)
{
second=0;
minute++;
if(minute>59)
{
minute=0;
hour++;
}
}
}
void Display()
{
uchar s0,s1;
uchar m0,m1;
uchar h0,h1;
s0=second/10;
s1=second%10;
m0=minute/10;
m1=minute%10;
h0=hour/10;
h1=hour%10;
s0+=0x30;
s1+=0x30;
m0+=0x30;
m1+=0x30;
h0+=0x30;
h1+=0x30;
LcdShowStr1(4,0,h0);
LcdShowStr1(5,0,h1);
LcdShowStr1(7,0,m0);
LcdShowStr1(8,0,m1);
LcdShowStr1(10,0,s0);
LcdShowStr1(11,0,s1);
}
*/
void DS1302_Time()
{
//for(index=0; index<7; index++)
//{
//time[index] = DS1302SingleRead(index);
DS1302BurstRead(time);
//}
if(psec != time[0])
{
str[0] = '2';
str[1] = '0';
str[2] = (time[6] >> 4) + 0x30;
str[3] = (time[6] & 0x0F) + 0x30;
str[4] = '-';
str[5] = (time[4] >> 4) + 0x30;
str[6] = (time[4] & 0x0F) + 0x30;
str[7] = '-';
str[8] = (time[3] >> 4) + 0x30;
str[9] = (time[3] & 0x0F) + 0x30;
str[10] = '\0';
LcdShowStr(0, 0, str);
str[0] = (time[5] & 0x0F) + 0x30;
str[1] = '\0';
LcdShowStr(11, 0, "WEEK");
LcdShowStr(15, 0, str);
str[0] = (time[2] >> 4) + 0x30;
str[1] = (time[2] & 0x0F) + 0x30;
str[2] = ':';
str[3] = (time[1] >> 4) + 0x30;
str[4] = (time[1] & 0x0F) + 0x30;
str[5] = ':';
str[6] = (time[0] >> 4) + 0x30;
str[7] = (time[0] & 0x0F) + 0x30;
str[8] = '\0';
LcdShowStr(8, 1, str);
psec = time[0];
}
}
void DS18b20_Temp()
{
uchar ack;
uchar num0,num1;
int temp=0;
// ack=DS_Ready();
ack=GetTemp(&temp);
if(ack==0)
{
num1=temp>>4;
// num2=temp<<4;
// num2=num2>>4;
num0=num1/10+0x30;
num1=num1%10+0x30;
// num2=num2%10+0x30;
LcdShowStr1(0,1,'T');
LcdShowStr1(1,1,'H');
LcdShowStr1(2,1,' ');
LcdShowStr1(3,1,num0);
LcdShowStr1(4,1,num1);
// LcdShowStr1(5,1,'.');
// LcdShowStr1(6,1,num2);
}
else
{
// LcdShowStr1(0,1,'E');
// LcdShowStr1(1,1,'R');
// LcdShowStr1(2,1,'R');
// LcdShowStr1(3,1,'0');
// LcdShowStr1(4,1,'R');
LcdShowStr(0,1,"ERR0R");
}
DSStart();
}
void main()
{
/*下面六行程序關閉所有的IO口*/
P1DIR = 0XFF;P1OUT = 0XFF;
P2DIR = 0XFF;P2OUT = 0XFF;
P3DIR = 0XFF;P3OUT = 0XFF;
P4DIR = 0XFF;P4OUT = 0XFF;
P5DIR = 0XFF;P5OUT = 0XFF;
P6DIR = 0XFF;P6OUT = 0XFF;
// uchar i;
WDTCTL = WDTPW + WDTHOLD;
InitLcd1602();
// TACTL=TASSEL_2;
// Lcd_Move();
Time0_Init(); //定時器使用32768,250ms
DS1302_Init();
DSStart();
_EINT();
// LcdShowStr(0,1," CLOCK TIME ");
// LcdShowStr1(6,0,':');
// LcdShowStr1(9,0,':');
// LcdShowStr(0,0," : : ")
while(1)
{
// LcdShowStr(1,0,"w23123123!");
// LcdShowStr(0,1,"hongchao 123");
if(flash)
{
flash=0;
DS1302_Time();
DS18b20_Temp();
// LcdShowStrLen(1,0,LcdMove+index,16);
// index++;
//if(index>sizeof(LcdMove))
// {
// index=0;
// }
// Display();
}
}
}
#pragma vector =TIMERA0_VECTOR
__interrupt void TIME_A()
{
// T500MSfg++;
flash=1;
//if(T500MSfg>2)
// {
// T500MSfg=0;
// flash=1;
// clock();
// }
}
復制代碼
全部資料51hei下載地址:
demo.zip
(54.25 KB, 下載次數: 46)
2019-4-14 09:23 上傳
點擊文件名下載附件
基于MSP430的實時時鐘及溫度顯示
下載積分: 黑幣 -5
作者:
xxyyss
時間:
2019-4-14 22:34
非常不錯,謝謝分享
作者:
9187640908
時間:
2019-4-19 14:41
謝謝分享
作者:
281778118
時間:
2019-5-23 18:35
作者請問
在運行你這個程序后出現這個怎么解決啊 function"get Temp"declared implicitly
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1