?? main.c
字號:
#include <intr740.h>
#include "sfr_7549.h"
#include "main.h"
#include "intf_7549.h"
bit FlagSeriousError;//E2 E5 E6 E7
// test
char itest;
//SerialOutputControl
zpage char tempControl=0xfe;
//start
zpage char Initial1s=0;//should be char
//check pan
bit FlagPan;
bit InitialCheckPan;
bit InitialCountineCheckPan;
bit InitialErrorDisplayPan;
bit FlagErrorDisplayPan;
bit CountineCheckPan;
bit FlagFun_CheckPan;
char CountTiguo=0;//for tiguo decet delay
char CountJianGuo=0;
//check IGBT panel power volt
bit FlagPowerVoltHigh;
bit FlagPowerVoltLow;
bit Temp1FlagPowerVoltHigh;
bit Temp1FlagPowerVoltLow;
bit Temp2FlagPowerVoltHigh;
bit Temp2FlagPowerVoltLow;
bit InitialTempFlagPowerVolt;
bit FlagIGBTOverHeat;
bit FlagIGBTError;//short or open
bit FlagPanelError;
bit FlagPanelOverHeat;
bit InitialErrorDisplayIGBT;
bit InitialCheckIGBT;
bit FlagHardwareError;
//surge_protect
//A/D
/* Definition Of 10bit-ADC Variable */
char CountTempertureIGBT;
char CountTempertureT_Main;
char CountTempertureCur_Sample=0;
char CountADchannel=0;//voltage,current,pan temp,igbt temp
const char ADChannelSerialSetup[4]={ADcon_volt,ADcon_curn,ADcon_igbt,ADcon_main};
int ADValue[4]={0x23f,0x01E,0x03D,0x07B};//voltage,current,pan temp,igbt temp
#define ADdata_volt ADValue[0]
#define ADdata_curn ADValue[1]
#define ADdata_igbt ADValue[2]
#define ADdata_main ADValue[3]
char Ad_a,Ad_b;
int AD_t;
typedef union
{
int a;
struct
{
unsigned char dataL;
unsigned char dataH;
}AD_BYTE;
}AD_WORD;
AD_WORD ad_data;
zpage int ADarray_volt[4]={0x23f,0x23e,0x23D,0x23a}; /* array of sample data */
zpage signed char counter_AD=0;
char counter_AD1=0;
//start
bit StatusRun;
//all func
bit FlagDuanXuHeat;
bit Initial3min;
bit Initial20min;
bit InitialK;
char FuncSerial=8;// zhufan=0 , shaokao(auto)=1,shaoshui=2,zhengdun=3,jianchao(auto)=4,huoguo(auto)=5,aozhou=6,baotang=7,non=8
//zhengdun
bit Initial1h;
bit Flag_DuanXuHeat;
bit InitialDuanXuHeat;
//key scan
const char keylist[16]={1,6,4,0xff,3,2,0xff,5,12,7,9,0xff,10,11,0xff,8};//frist 8bit for dataport second 8bit for key port
//key process
char KeyValue;
char keytemp1;
char keytemp2;
char KeyBuf;
bit KeyScanCs;
bit LongKeyCs;
char FlagBuf;//save keybuf
char TempA;
bit KeyAnswer;
bit FlagYuYueDingShiTimeVaid;//=1 set!0 number, =0 donnot setup any number to yuyuedingshi
unsigned int CountTest;
char countMin;
char countHour;
char TempDisp0=0;
char TempDisp1=0;
char TempDisp2=0;
char TempDisp3=0;
char Temp0=0;
char Temp1=0;
char Temp2=0;
char Temp3=0;
char CountKeyCycle=0;
bit FlagSynchronous;
bit FlagFuncEnable;
bit FlagFunc_YuYueDingShi;
bit FlagDisableTwinkle_SetupYuYueDingShi;//press key =1, release key =0 in setup yuyuedingshi
bit FlagSetOver_SetupYuYueDingShi;
typedef union{
char ubyte ;
struct{
char _0 : 1 ;
char _1 : 1 ;
char _2 : 1 ;
char _3 : 1 ;
char _4 : 1 ;
char _5 : 1 ;
char _6 : 1 ;
char _7 : 1 ;
}bitf ;
} bytestr ;
//bytestr keydatatemp1;
//bytestr keydatatemp2;
bytestr Func;
#define FlagFunc_ShaoShui Func.bitf._0
#define FlagFunc_ZhengDun Func.bitf._1
#define FlagFunc_AoZhou Func.bitf._2
#define FlagFunc_Zhufan Func.bitf._3
#define FlagFunc_HuoGuo Func.bitf._4
#define FlagFunc_ShaoKao Func.bitf._5
#define FlagFunc_JianChao Func.bitf._6
#define FlagFunc_BaoTang Func.bitf._7
bytestr Power;//for auto func power duanxu jiare
char TempPower=0;
#define FlagAutoFunc200W Power.bitf._0
#define FlagAutoFunc400W Power.bitf._1
#define FlagAutoFunc800W Power.bitf._2
#define FlagAutoFunc1000W Power.bitf._3
#define FlagAutoFunc1200W Power.bitf._4
#define FlagAutoFunc1400W Power.bitf._5
#define FlagAutoFunc1600W Power.bitf._6
#define FlagAutoFunc1800W Power.bitf._7
const char LEDDisp[18]={0xA0,0xBD,0xC1,0x89,0x9C,0x8A,0x82,0xAD,0x80,0x88,0xdf,0x20,0x40,0x80,0x04,0x08,0xff,0x00};
// 0 1 2 3 4 5 6 7 8 9 - L1L6 L2L7 L3L8 L4L9 L5L10
#define DispLed_ZhuFan LEDDisp[11]//disp[4]
#define DispLed_AoZhou LEDDisp[12]//disp[4]
#define DispLed_YuYueDingShi LEDDisp[13]//disp[4]
#define DispLed_BaoTang LEDDisp[14]//disp[4]
#define DispLed_ShaoKao LEDDisp[15]//disp[4]
#define DispLed_JianChao LEDDisp[11]//disp[5]
#define DispLed_HuoGuo LEDDisp[12]//disp[5]
#define DispLed_ZhenDun LEDDisp[13]//disp[5]
#define DispLed_ShaoShui LEDDisp[14]//disp[5]
#define DispLed_Power LEDDisp[15]//disp[5]
#define DispLed_Dp 0x80//disp 1
#define Displed_Off 16//0xff
#define Displed_On 17//0x00
char Disp[6]={0xA0,0xA0,0xA0,0xA0,0xA0,0xA0};//led0-3=disp0-3,disp 4 (l1-l5),disp5(l6-l9) group led
//COMMON anode
// 0xA0,F5/*0*/
// 0xBD,F4/*1*/
// 0xC1,F3,/*2*/
// 0x89,F7/*3*/
// 0x9C,F6/*4*/
// 0x8A,F7/*5*/
// 0x82,/*6*/
// 0xAD,/*7*/
// 0x80,/*8*/
// 0x88,/*9*/
// 0x84,/*A*/
// 0x92,/*b*/
// 0xE2,/*C*/
// 0xD3,/*c*/
// 0x91,/*d*/
// 0xC2,/*E*/
// 0xC6,/*F*/
// 0x94,/*H*/
// 0x96,/*h*/
// 0xF2,/*L*/
// 0x97,/*n*/
// 0xA4,/*N*/
// 0x93,/*o*/
// 0xC4,/*P*/
// 0xD7,/*r*/
// 0xD2,/*t*/
// 0xB0,/*U*/
// 0xDF,/*-*/
//COMMON cathode
// 0x5F,/*0*/
// 0x42,/*1*/
// 0x3E,/*2*/
// 0x76,/*3*/
// 0x63,/*4*/
// 0x75,/*5*/
// 0x7D,/*6*/
// 0x52,/*7*/
// 0x7F,/*8*/
// 0x77,/*9*/
// 0x7B,/*A*/
// 0x6D,/*b*/
// 0x1D,/*C*/
// 0x2C,/*c*/
// 0x6E,/*d*/
// 0x3D,/*E*/
// 0x39,/*F*/
// 0x6B,/*H*/
// 0x69,/*h*/
// 0x0D,/*L*/
// 0x68,/*n*/
// 0x5B,/*N*/
// 0x6C,/*o*/
// 0x3B,/*P*/
// 0x28,/*r*/
// 0x2D,/*t*/
// 0x4F,/*U*/
//yuyue
int Tempcount_20min=0;
char Tempcount_3min=0;
bit TempFlag30sBaotang;//need not initial
bit TempFlag3Min;//need not initial
bit TempFlag2Min;//need not initial
char PowerSerial=8; //1800W=0,1600W=1.1400W=2,1200W=3,1000W=4,800W=5,400W=6,200W=7,non=8,
const char AutoPowerSerial[8]={CMP01_L_1800W,CMP01_L_1600W,CMP01_L_1400W,CMP01_L_1200W,CMP01_L_1000W,
CMP01_L_800W,CMP01_L_800W,CMP01_L_800W};
const char DispPowerSerial[16]={0xbd,0xbd,0xbd,0xbd,0xbd,0xff,0xff,0xff,
0x80,0x82,0x9c,0xc1,0xa0,0x80,0x9c,0xc1};//display 1,1,1,1,1,0xff,0xff,0xff,8,6,4,2,0,8,4,2
const char DispPowerTemparatureSerial[16]={0xc1,0xc1,0xc1,0xbd,0xbd,0xbd,0xbd,0xff,
0x82,0x9c,0xa0,0x80,0x82,0xc1,0xa0,0x80};//display 2,2,2,1,1,1,1,0xff,6,4,0,8,6,2,0,8
//const char DispFuncLedSerial[16]={0x00,0x00,0x04,0x20,0x40,0x00,0x00,0x08,
// 0x0c,0x88,0x08,0x08,0x08,0x48,0x28,0x80};//diplay disp[4] 8bit and disp[5] 8bit ,if and yuyue must +0x80 to disp[4]
//yuyuedingshi,yuyuedingshi,yuyuedingshi+baotang,yuyuedingshi+zhufan,yuyuedingshi+aozhou,yuyuedingshi,yuyuedingshi,yuyuedingshi+shaokao,
//shaoshui+power,zhendun+power,power,power,power,power+huoguo,power+jianchao,power
const char DispFuncLedSerial[16]={0x20,0x08,0x00,0x00,0x00,0x00,0x40,0x04,
0x08,0x08,0x0c,0x88,0x28,0x48,0x08,0x08,};//func +power diplay disp[4] 8bit and disp[5] 8bit ,if and yuyue must +0x80 to disp[4]
void init_sfr(void)
{
/* set PORT */
//P0D=0xff;//po output
P0D = 0xFC; /* only INT,PAN input from wg */
PULL0=0xff;//po pull up
P0=0xff;//po output high
//P1D=0xff;//po output
P1D = 0x49; /* only AD, KEY input from wg */
//PULL1=0xff;//po pull up
//P1=0xff;//po output high
P1=0x00;//po output low
P1D.7=0;//p1.7 input
P3D = 0xFF; /* K output */
P3=0;
/* set Time 1 */
IR_T1=0;
//PRE12=19;
//T1=199; /* timer1 10*106*2us */
IE_T1=1; /*enable t1*/
PRE12=9;
//T1=105; /* timer1 10*100*2us=2ms */
//T1=99;
T1=98;//modified
TCSS.5=0; /*timer1 Prescaler 12 count source selection bit
0 : φSOURCE/16
1 : XCIN input clock
(32kHz quartz crystal oscillation) */
/* set Time 2 */
T2STP=1; /* stop T2 */
T2CK0=0; /* Timer2 Count Source = xin/16/pre12 */
T2CK1=1;
T2CK2=0;
//PRE12 = 0x;//00; /* 8MHz/16/PRE12 = 2us */
T2=19;//0x84; /* 268us buzzer freq */
#if buzzerPwm==0
T2OCNT=0;//1; /* P13/T2out Output Valid Bit */
#endif
#if buzzerPwm==1
T2OCNT=1;//0; /* P13/T2out Output Valid Bit */
#endif
T2OEDG=1; /* T2out Active Edge Switch Bit */
T2WC=0; /* Timer 2 Write Control Bit */
/* set TimerA interruption */
IE_TA=1; /* TimerA interrupt enable */
IR_TA=0; /* clear TimerA interrupt require */
/* set Time A and CMP0 (PWM) */
TASTP=1; /* stop TA */
TAWC=0; /* Timer A Write Control Bit */
TACK0=0; /* TimerA Count Source = xin/16 */
TACK1=0;
TACK2=0;
TAL=0xFF; /* PWM_cyc = 512us */
TAH=0x00;
CMOM = 0x09; /* Compare 0 output positive, trigger enable */
CCRP = 0x00; /* Selecte Latch 00 */
CRAL = CMP00_L; /* Write low-order of compare 00 */
CRAH = CMP00_H; /* Write high-order of compare 00 */
CCRP = 0x01; /* Selecte Latch 01 */
//CRAL = CMP01_L; /* Write low-order of compare 01 */
//CRAH = CMP01_H; /* Write high-order of compare 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 */
CCPR = 0x02; /* P11-P12 are I/O ports */
CCSR = 0x00; /* Compare 0 "H" */
CISR = 0x01; /* Compare latch 00,10 interrupt source enable */
TASTP = 0; /* start TA */
//T2STP = 0; /* start T2 */
/* set INT0 and INT1 */
PU00 = 1;
INT0PL = 0;
IE_INT0 = 1;
IR_INT0 = 0;
PU01 = 1;
INT1PL = 0;
IE_INT1 = 1;
IR_INT1 = 0;
}
void init_GolbalVariable(void)
{
Flag1s=0;//must initial
Flag1sStart=0;//must initial ,only for start subprogrom
Flag1Min=0;//must initial
Flag2Min=0;
Flag3Min=0;
Flag40s=0;
Flag30sBaotang=0;
FlagFuncEndProssTimer=0;
EnableYuYueCounter=1;
buzzer_on_flag=0;
FlagPan=0;
StatusRun=0;
FlagSynchronous=0;
Func.ubyte=0;
FlagFuncEnable=0;
FlagFunc_YuYueDingShi=0;
FlagDisableTwinkle_SetupYuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
Flag5sTwinkle=0;
Flag500msTwinkle=0;
FlagSurgeProtect=0;
FlagIGBTError=0;
FlagIGBTOverHeat=0;
FlagPanelError=0;
FlagPanelOverHeat=0;
FlagPowerVoltHigh=0;
FlagPowerVoltLow=0;
FlagYuYueDingShiTimeVaid=0;
CountTempertureIGBT=0;
CountTempertureT_Main=0;
CountTempertureCur_Sample=0;
InitialCheckPan=1;//power up disable check pan ,when func enable then check pan
InitialK=0;//initial k give pluse
InitialCountineCheckPan=0;
CountineCheckPan=0;
InitialErrorDisplayPan=0;
InitialErrorDisplayIGBT=0;
FlagFun_CheckPan=0;
InitialCheckIGBT=0;
FlagErrorDisplayPan=0;
Flag30s=0;
FlagSeriousError=0;
FlagHardwareError=0;
Temp1FlagPowerVoltHigh=0;
Temp1FlagPowerVoltLow=0;
Temp2FlagPowerVoltHigh=0;
Temp2FlagPowerVoltLow=0;
InitialTempFlagPowerVolt=0;
Power.ubyte=0;
InitialDuanXuHeat=0;
}
void SerialOutputProcess(char data8)
{
char i;
char temp;
temp=data8;
for(i=0;i<8;i++)
{
if((temp&0x01)==1)
{
DataPort=1;
}
else
{
DataPort=0;
}
DataPortClk=0;
//nop_instruction();
DataPortClk=1;
//nop_instruction();
temp=temp>>1;
}
}
void KeyFuncSetupInitial(void)
{
buzzer_on_flag=1;
FlagFuncEnable=1;
InitialCheckPan=0;//pan check initial
InitialK=0;//initial (k give pluse)
Initial20min=0;//for auto func set
Initial3min=0;//for auto func set
CountineCheckPan=0;//initial error display
FlagPan=0;
FlagFun_CheckPan=1;
FlagFunc_YuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
EnableYuYueCounter=1;
FlagYuYueDingShiTimeVaid=0;//initial
//Flag_DuanXuHeat=0;
}
void PowerSerialSearch(void)
{
if(FlagAutoFunc1800W)
{
PowerSerial=0;
}
else if(FlagAutoFunc1600W)
{
PowerSerial=1;
}
else if(FlagAutoFunc1400W)
{
PowerSerial=2;
}
else if(FlagAutoFunc1200W)
{
PowerSerial=3;
}
else if(FlagAutoFunc1000W)
{
PowerSerial=4;
}
else if(FlagAutoFunc800W)
{
PowerSerial=5;
}
else if(FlagAutoFunc400W)
{
PowerSerial=6;
}
else if(FlagAutoFunc200W)
{
PowerSerial=7;
}
}
void DuanXuHeatProcess(void)
{
if(FlagDuanXuHeat)
{
if(InitialDuanXuHeat==0)//for k
{
InitialDuanXuHeat=1;
InitialCheckPan=0;//fristly check pan check pan must before shaoshui
InitialK=0;//finially k
}
}
else
{
K=0;
InitialDuanXuHeat=0;
}
}
void KeyDecreaseIncreaseFunc(void)
{
if(KeyValue==Key_Decrease)
{
countHour++;
}
if(KeyValue==Key_Increase)
{
countMin++;
}
if (countHour>9)
{
countHour=0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -