WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
// SCFI0 |= FN_4; // x2 DCO frequency, 8MHz nominal DCO
// SCFQCTL = 121; // (121+1) x 32768 x 2 = 7.99 Mhz
// FLL_CTL0 = DCOPLUS + XCAP18PF; // DCO+ set so freq = xtal x D x N+1
FLL_CTL1 = FLL_CTL1 & ~XT2OFF; // clear bit = high freq xtal on
do // loop until flag is clear
{
FLL_CTL0 = FLL_CTL0 & ~XT2OF; // clear high freq oscillator fault flag
for (i = 0; i<50000; i++); // delay for crystal to start and FLL to lock
}
while (FLL_CTL0 & XT2OF); // test high freq oscillator fault flag
// if flag remained clear then -
FLL_CTL1 = SELS+SELM_XT2; // switch MCLK=SMCLK = HF xtal
//====开机判键修正===//
P2DIR=0x00; //p2.0~p2.7input mode
P2IE=0x00;
if (!(P2IN&0X02))
{power_amend_measure();
}
if (!(P2IN&0X20))
{amp_amend_measure();
}
Init();
_EINT();
while(1)
{if (frequency_flag==1)
{frequency_flag=0;
dspl_flag=6;
frequency_measure();
}
if (positive_power_flag==1)
{
positive_power_flag=0;
dspl_flag=3;
positive_power_measure();
}
if (negative_power_flag==1)
{
negative_power_flag=0;
dspl_flag=3;
negative_power_measure();
}
if (current_flag==1)
{
current_flag=0;
dspl_flag=3;
current_measure();
}
if (ratio_flag==1)
{
ratio_flag=0;
dspl_flag=4;
ratio_measure();
}
if (amp_flag==1)
{
amp_flag=0;
dspl_flag=3;
amp_measure();
}
if (amp_amend_flag==1)
{
amp_amend_flag=0;
dspl_flag=6;
amp_amend_measure();
}
if (power_amend_flag==1)
{
power_amend_flag=0;
dspl_flag=6;
power_amend_measure();
}
if (!(P1IN&BIT1)) //输入为低电平表示有键按下,执行电流修正函数
{current_amend_measure();
}