MSP430G2553做DS18B20温度控制器
_s_L=5;
}
if(temp_s_flag==1&&temp_s_M==5&&(temp_s_L>5))
{
temp_s_L=5;
}
LCD1602_4bit_CMD(0xc0+0x0c);
LCD1602_4bit_Data(0x30+temp_s_L);
}
while((P1IN&BIT4)==0)
{}
}
}
}
void display(void)
{
temp=(temp_H&0x0f)<4;
if((temp_H&0xf0)==0xf0)
{
LCD1602_4bit_CMD(0x85);
LCD1602_4bit_Data(0x2d);
}
else
{
LCD1602_4bit_CMD(0x85);
LCD1602_4bit_Data(0x20);
}
temp=temp|((temp_L&0xf0)>>4);
LCD1602_4bit_CMD(0x86);
LCD1602_4bit_Data(0x30+temp/100);
LCD1602_4bit_CMD(0x87);
LCD1602_4bit_Data(0x30+(temp%100)/10);
LCD1602_4bit_CMD(0x88);
LCD1602_4bit_Data(0x30+temp%10);
}
void warning(void)
{
if(temp_s_flag==0)
{
if(temp>=(temp_s_L*100+temp_s_M*10+temp_s_L))
{P2OUT|=BIT5;}
else
{P2OUT&=~BIT5;}
}
if(temp_s_flag==1)
{
if(temp<=(temp_s_M*10+temp_s_L))
{P2OUT|=BIT5;}
else
{P2OUT&=~BIT5;}
}
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
DCOCTL = 0x00; // Set DCO 1MHz
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
//time0_int();
_EINT();
P2DIR |= 0x0f;
P1DIR |= 0xf0;
delay_ms(20);
io_int();
LCD1602_4bit_init();
for(i1=0; i1<5; i1++)
{
LCD1602_4bit_CMD(0x80+i1);
LCD1602_4bit_Data(table_1[i1]);
}
for(i1=0; i1<4; i1++)
{
LCD1602_4bit_CMD(0xc0+i1);
LCD1602_4bit_Data(table_2[i1]);
}
while(1)
{
// LCD1602_4bit_CMD(0x85);
// LCD1602_4bit_Data(0x30+time_num);
Read_temp();
key_scan();
display();
warning();
/* P2OUT|=BIT5;
delay_ms(2000);
P2OUT&=~BIT5;
delay_ms(2000);
P1OUT&=~BIT6;
delay_ms(1000);*/
}
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void timeA1(void)
{
time_num++;
if(time_num==20)
{
time_num=0;
}
}
MSP430G2553DS18B20温度控制 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)