void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset
FLL_CTL0|=XCAP18PF; //设置晶振匹配电容为18pf左右
LCDCTL=LCDON+LCD4MUX+LCDSG0_1;
P5SEL=0xFC;
P2DIR&=~BIT1; //P2.1设为输入
P2IES|=BIT1; //P2.1设为下降沿中断
P2IE|=BIT1; //允许P2.1中断
P2IFG=0; //清除P2中断标志位
BTCTL=BT_ADLY_1000+BT_fLCD_256; //BasicTimer clock选为ACLK,1/64s(约16ms)中断一次,LCD刷新频率256Hz
IE2=BTIE; //允许BasicTimer中断
_EINT(); //允许总中断
while(1)
{
P6DIR|=BIT6; //红LED
P6OUT|=BIT6;
LPM3; //进入低功耗模式3,等待被唤醒。以下程序每1/64s执行一次
P6DIR|=BIT5; //绿LED
P6OUT^=BIT5;
LCDM1=0X00;
LCDM2=0X00;
LCDM3=0X00;
LCDM4=0X00;
LCDM5=0X00;
Battery_mAH=1200;
LCD_DisplayAll();
}
}
//.............BT中断.........................//
#pragma vector=BASICTIMER_VECTOR
__interrupt void BT_ISR(void) //1/64s一次中断(由BasicTimer所产生)
{
__low_power_mode_off_on_exit(); //退出时唤醒cpu
}
//............按键中断........................//
#pragma vector=PORT2_VECTOR //P2口中断源
__interrupt void P2_ISR(void)
{
if((P2IFG&BIT1)==0) //判断P2.1
{
key_value=1;
P6OUT&=~BIT6;
}
}
目前的情况是上电,基础定时器工作正常,绿灯闪,红灯亮;但是,一按按键,绿灯和红灯都常亮了,求高手查查问题出在哪里,谢谢啦 |