📄 init.c
字号:
#include "MATH.H"
#include "STC12.H"
#include "function.h"
#include "pin.h"
#include "evariable.h"
void init(void)
{
// delay2(1000);
MCU_INIT();
k_pw=0;
switch_5v=0;
//store character address
sear_dpl();
//close display
// lcd_commd=0xae;
// LCD_WriteIR1();
//close display
// lcd_commd=0xae;
// LCD_WriteIR2();
EA=1;
}
void MCU_INIT(void)
{
unsigned char flag1,flag2;
//PCA
CCON=0;
// CMOD|=0x00;// ECF=1;PCA Clok=Fosc/12
// CMOD|=0x02;// ECF=0;PCA Clok=Fosc/2
//PCA1
CCAPM1|=0x11;//CAPP2=1;ECCF2=1;下降沿触发中断
//PCA3
CCAPM3|=0x11;//CAPP3=1;ECCF3=1;下降沿触发中断
//PCA0 used as Time to 27ms per a time
CCAP0H=0x46;
CCAP0L=0x82;
CCAPM0|=0x49;//ECOM0=1,MAT0=1,ECCF0=1
CR=1;
//active the PCA
EPCA_LVD=1;
CH=0;
CL=0;
//t_a :P3.4
P3M0|=0x10;
P3M1&=0xef;
//t_b :P3.5
P3M0|=0x20;
P3M1&=0xdf;
CR=1;
//ex0:hp--P3.2
P3M0|=0x04;
P3M1&=0xfb;
EX0=0;
//ex1:lp--P3.3
P3M0|=0x08;
P3M1&=0xf7;
EX1=0;
//P1.1---Key-in
P1M0|=0x02;
P1M1&=0xfd;
//P1.4---temp-in
P1M0|=0x10;
P1M1&=0xef;
dz0=0;
dz1=0;
dz2=0;
dz3=0;
dz4=0;
CS=1;
DA=0;
CLK=0;
SPEAKER=1;
alarm=0;
alarm_state=0;
cnt_fa=0;
da_WA=99;
da_TC=15;
state_fa=0;
state_Lp=0;
state_Hp=0;
state_ref=0xff;
ref=0;
//FRESH AIR: 0 indicate OFF state
// 1 indicate ON state
// 2 indicate AUTO state
k_fa=0 ;
//send air open at power on
sendair=1;
//freshair init state
freshair_aut=0;
freshair=0;
alarm=0;
cnt_main=0;
cnt_Ref=0;
cnt_Ee=0;
cnt_WA=0;
cnt_Resume=0;
cnt_Sens=0;
cnt_Hp=0;
cnt_Lp=0;
cnt_fa=0;
cnt_Display=0;
cnt_Sens=0;
//store data in ee
EE_Read(0x2900,&flag1,1);
EE_Read(0x2901,&flag2,1);
if((flag1!=0x33)&&(flag2!=0x33))
{
flag1=0x33;
flag2=0x33;
EE_Erase(0x2800);
EE_Write(0x2900,&flag1,1);
EE_Write(0x2901,&flag2,1);
da_TA=20;
EE_Write(0x2800,&da_TA,1);
}
else
{
EE_Read(0x2800,&da_TA,1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -