📄 main.c
字号:
if(FlagAutoFunc400W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
else
{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[0];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
}
if(FlagFunc_BaoTang)
{
if(FlagAutoFunc800W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
else
{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
}
if(FlagFunc_ZhengDun)
{
if(FlagAutoFunc800W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
else
{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
}
if((FlagFunc_HuoGuo)||(FlagFunc_JianChao))
{
Disp[0]=DispPowerSerial[PowerSerial];
Disp[1]=DispPowerSerial[PowerSerial+8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
}
if(FlagFunc_ShaoKao)
{
Disp[0]=0xff;
Disp[1]=DispPowerTemparatureSerial[PowerSerial];
Disp[2]=DispPowerTemparatureSerial[PowerSerial+8];
Disp[3]=LEDDisp[0];
}
}
Disp[4]=DispFuncLedSerial[FuncSerial]+DispLed_YuYueDingShi;
Disp[5]=DispFuncLedSerial[FuncSerial+8];
}
else//in yuyue setup mode , is setuping
{
if(Flag500msTwinkle==0)
{
if(FlagDisableTwinkle_SetupYuYueDingShi==1)//in longkey mode disable twinkle
{
Disp[0]=TempDisp0;
Disp[1]=TempDisp1;
Disp[2]=TempDisp2;
Disp[3]=TempDisp3;
Disp[4]=DispFuncLedSerial[FuncSerial]+DispLed_YuYueDingShi;
Disp[5]=DispFuncLedSerial[FuncSerial+8];
}
else //enable twinkle
{
Disp[0]=0xff;//turn off all led
Disp[1]=0xff;
Disp[2]=0xff;
Disp[3]=0xff;
Disp[4]=DispFuncLedSerial[FuncSerial];
Disp[5]=DispFuncLedSerial[FuncSerial+8];
}
}
else
{
Disp[0]=TempDisp0;
Disp[1]=TempDisp1;
Disp[2]=TempDisp2;
Disp[3]=TempDisp3;
Disp[4]=DispFuncLedSerial[FuncSerial]+DispLed_YuYueDingShi;
Disp[5]=DispFuncLedSerial[FuncSerial+8];
}
}
}
}
void Func_AllFunc(void)
{
char i;
if(Func.ubyte!=0)//func enable
{
//light shaoshui led display 1800w
if((FlagFunc_YuYueDingShi==0)
&(FlagErrorDisplayPan==0)&(FlagPowerVoltHigh==0)&(FlagPowerVoltLow==0)&(FlagPan==1))//yuyuedingshi is not undertask
{ //or in auto func(despite yuyue or not)
FAN=1;//open fun
if(FlagFunc_ShaoShui)
{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
Disp[4]=0x00;
Disp[5]=DispLed_ShaoShui+DispLed_Power;
//set pwm
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_1800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_1800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
if(FlagFunc_ZhengDun)
{
//if(Flag_DuanXuHeat)
if(FlagAutoFunc800W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
else{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_1400W; /* Write low-order of compare 01 */
CRAH = CMP01_H_1400W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
Disp[4]=0x00;
Disp[5]=DispLed_ZhenDun+DispLed_Power;
}
if(FlagFunc_BaoTang)
{
//if(Flag_DuanXuHeat)
if(FlagAutoFunc800W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
else{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_1400W; /* Write low-order of compare 01 */
CRAH = CMP01_H_1400W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
Disp[4]=DispLed_BaoTang;
Disp[5]=DispLed_Power;
}
if(FlagFunc_Zhufan)
{
//if(Flag_DuanXuHeat)
if(FlagAutoFunc400W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
else{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[0];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_1000W; /* Write low-order of compare 01 */
CRAH = CMP01_H_1000W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
Disp[4]=DispLed_ZhuFan;
Disp[5]=DispLed_Power;
}
if(FlagFunc_AoZhou)
{
//if(Flag_DuanXuHeat)
if(FlagAutoFunc800W)
{
Disp[0]=0xff;
Disp[1]=LEDDisp[8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
else{
Disp[0]=LEDDisp[1];
Disp[1]=LEDDisp[4];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_1400W; /* Write low-order of compare 01 */
CRAH = CMP01_H_1400W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
}
Disp[4]=DispLed_AoZhou;
Disp[5]=DispLed_Power;
}
if((FlagFunc_HuoGuo)||(FlagFunc_JianChao))//auto func
{
Disp[0]=DispPowerSerial[PowerSerial];
Disp[1]=DispPowerSerial[PowerSerial+8];
Disp[2]=LEDDisp[0];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = AutoPowerSerial[PowerSerial]; /* Write low-order of compare 01 */
CRAH = 0x00; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
if(FlagFunc_HuoGuo)
{
Disp[4]=0x00;
Disp[5]=DispLed_Power+DispLed_HuoGuo;
}
else if(FlagFunc_JianChao)
{
Disp[4]=0x00;
Disp[5]=DispLed_Power+DispLed_JianChao;
}
}
if(FlagFunc_ShaoKao)//auto func
{
Disp[0]=0xff;
Disp[1]=DispPowerTemparatureSerial[PowerSerial];
Disp[2]=DispPowerTemparatureSerial[PowerSerial+8];
Disp[3]=LEDDisp[0];
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = AutoPowerSerial[PowerSerial]; /* Write low-order of compare 01 */
CRAH = 0x00; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
Disp[4]=DispLed_ShaoKao;
Disp[5]=DispLed_Power;
}
}
//setup pwm
//check pan subprogram if FlagPan=1 then PanIn or Panout
if(FlagPan==1)// valid pan in cooker
{
if((FlagFunc_YuYueDingShi==0)||(FlagFunc_ShaoKao)||(FlagFunc_HuoGuo)||(FlagFunc_JianChao))//yuyue process is over remember clear it when return to other func
{
if((FlagSurgeProtect==0)&(FlagPowerVoltHigh==0)&(FlagPowerVoltLow==0))
{
if(InitialK==0)
{
InitialK=1;
disable_interrupt();
PAN=0;
P0D.0=1;//output
K=1;//9us enable
for(i=0;i<5;i++)//for k
{
nop_instruction();
}
PAN=1;
P0D.0=0;//change to input
IR_INT0=0;//clear ir requre
IR_INT1=0;//clear ir requre
for(i=0;i<8;i++)//for int
{
nop_instruction();
}
enable_interrupt();
}
if(FlagAutoFunc800W)//
{
FlagDuanXuHeat=Flag7500mS800W;
DuanXuHeatProcess();
}
else if(FlagAutoFunc400W)
{
FlagDuanXuHeat=Flag5000mS400W;
DuanXuHeatProcess();
}
else if(FlagAutoFunc200W)
{
FlagDuanXuHeat=Flag2500mS200W;
DuanXuHeatProcess();
}
else if(K==0)//test for drive henxiang
{
InitialK=0;//open k
}
}
if(ADdata_main>=0x150)//cooker T above 85 oC actual 970c auto func have not this func except shaokao
{
if(FlagFunc_ShaoShui)
{
if(Initial3min==0)
{
count_1s=0;
count_3min=0;
Initial3min=1;
Flag3Min=0;
}
if(Flag3Min==1)//remember clear it when return to other func
{
K=0;//close IGBT
//only for isolator test , when product should change to cmp01_L;
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow *///close pwm
Flag3Min=0;
Func.ubyte=0x00;//close all func
FlagFuncEnable=0;
FlagFunc_YuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
//Initial1s=0;//display start twinkle
Flag40s=0;
Flag1Min=0;
count_1min=0;
}
}
if(FlagFunc_ZhengDun)
{
if(Initial3min==0)
{
count_1s=0;
count_3min=0;
Initial3min=1;
Flag3Min=0;
}
if(Flag3Min==1)//remember clear it when return to other func
{
FlagAutoFunc800W=1;
}
}
if(FlagFunc_AoZhou)
{
if(Initial3min==0)
{
count_1s=0;
count_3min=0;
Initial3min=1;
Flag2Min=0;
}
if(Flag2Min==1)//remember clear it when return to other func
{
FlagAutoFunc800W=1;
}
}
if(FlagFunc_Zhufan)
{
if(Initial3min==0)
{
count_1s=0;
count_3min=0;
Initial3min=1;
Flag2Min=0;
}
if(Flag2Min==1)//remember clear it when return to other func
{
FlagAutoFunc400W=1;
}
}
if(FlagFunc_BaoTang)
{
if(Initial3min==0)
{
count_1s=0;
count_3min=0;
Initial3min=1;
Flag30sBaotang=0;
}
if(Flag30sBaotang==1)//remember clear it when return to other func
{
FlagAutoFunc800W=1;
}
}
}
#endif
if(Func.ubyte!=0x00)
{
if(Initial20min==0)//whole process timer
{
count_1s=0;
count_20min=0;
Initial20min=1;
FlagFuncEndProssTimer=0;
}
if(FlagFuncEndProssTimer==1)//remember clear it when return to other func
{
K=0;//close IGBT
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow *///close pwm//close pwm
FlagFuncEndProssTimer=0;
Func.ubyte=0x00;//close all func
Power.ubyte=0;
FlagFuncEnable=0;
FlagFunc_YuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
//Initial1s=0;//display start twinkle
Flag40s=0;
Flag1Min=0;
count_1min=0;
}
}
}
}
}
}
/*************************************************************************
Name : buzzer
Parameters : None
Returns : None
Description: buzzer
**************************************************************************/
void buzzer(void)
{
if(buzzer_on_flag)
{
T2OCNT=1;//change to t2out
T2STP=0; /* pulse output */
if(counter_120ms>=234) /* 234 x 512us(TA) */
{
T2STP=1;/* stop pulse output */
T2OCNT=0;//change to i/0 p1_3
BUZ=0;//clear buzzer
counter_120ms=0;
buzzer_on_flag=0; /* clear buzzer signal*/
}
}
}
void main(void)
{
disable_interrupt(); /* interrupt disable */
cld_instruction(); /* binary Arithmetic Executed */
#if 0
CLKM2 = 0; /* Start Xin */
nop_instruction();
nop_instruction();
nop_instruction();
CLKM5 = 1; /*select Xin */
CLKM4 = 0;
nop_instruction();
// Div 1: D-speed mode
CLKM7 = 1;
CLKM6 = 1;
nop_instruction();
#endif
CLKM =0xe3; /* double Mode, external clock */
nop_instruction();
init_sfr();/* initialize register */
init_GolbalVariable();
enable_interrupt();
while(1)
{
nop_instruction();
KeyProcess();
CheckPan();
CheckIGBT_Panel_PowerVolt();
surge_protection();
vol_cur_sample();
start();
buzzer();
Func_YuYueDingShi();
Func_AllFunc();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -