//restore R4
_asm
{
SWAPA 0x1F
MOV 0X04,A
}
}
void main()
{
uchar temp1,temp2;
uchar i,j;
uchar *r;
uchar b;
uchar c;
uchar stst;
uchar *w;
uchar x;
uchar y;
DISI();
tms(10);
sys_init();
//lcd_init(0xf7);
r_buf[0]=0;
r_buf[1]=0;
r=r_buf; //读参数
b=0x00;
c=2;
w=w_buf; //写参数
x=0x00;
y=2;
//w_buf[0]=0x81;
//w_buf[1]=0x19;
// wt24c(w,x,y); //出厂写EEPROM
rd24c(r,b,c); //初始读EEPROM
fan_st=r_buf[0];
set_temper=r_buf[1];
temp1=test_temperature();
for(i=0;i<32;i++)// 清屏
{
LCD_ADDR=i;
LCD_DB=0;
}
for(dly=0x1fff;dly;dly--)
{
WDTC();
}
//LED=1;
ENI();
while(1)
{
//key_find();
while(timer_2ms_ok)
{
timer_2ms_ok=0;
if(mode_on_off==1)
{
lcd_init(0xf7);
if(key_flag)
{
LED=1;
if(timer1>=200)
{
timer1=0;
LED=0;
if((r_buf[0]!=fan_st)||(r_buf[1]!=set_temper))
{
r_buf[0]=fan_st;
r_buf[1]=set_temper;
w_buf[0]=fan_st;
w_buf[1]=set_temper;
wt24c(w,x,y); //写
}
key_flag=0;
}
}
if(times>=250)
{
temp1=test_temperature();
times=0;
}
temp2=Bin1toBcd(set_temper);
display(temp1,fan_st,temp2);
PORT6=fan_st&0xe0;
stst=fan_st&0x01;
if(stst==0x01)
{
COOL=1;
HOT=0;
tms(1);
上一篇:EMC单片机指令应用的误区与技巧