|
#include "msp430f5529.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4DIR|=BIT7;
P4OUT&=~BIT7; P2IE |= BIT1; //設(shè)置p2.1可以中斷
P2IES |= BIT1; //設(shè)置p2.1為下降沿中斷
P2IFG &= ~BIT1;//設(shè)置p2.1為0 無(wú)中斷請(qǐng)求
P2REN |= BIT1; //設(shè)置p2.1為上下拉電阻使能
P2OUT |= BIT1;
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
#pragma vector=PORT2_VECTOR
__interrupt void Key_interrput()
{
if(P2IFG&BIT1)
{
Delay(50);
if(P2IFG&BIT1)
{
while((P2IN&BIT1)==0);//松手檢測(cè)
P2IFG &= ~BIT1; //清除中斷標(biāo)志位
P4OUT^=BIT7;
}
}
}
|
評(píng)分
-
查看全部評(píng)分
|