如何进行MSP430 LaunchPad IO外部按键中断的编程
[复制链接]
//功能: P1.3按键中断,P1.0LED翻转
#include
#include
void main( )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD; P1DIR |= BIT0;//设置P1.0口为输出
P1IE |= BIT3;//使能P1.3中断
P1IES |= BIT3;//P1.3口下降沿触发中断
P1IFG &= ~BIT3;//中断标志位清零 _EINT();//开总中断
_BIS_SR(LPM4_bits + GIE);
}
#pragma vector = PORT1_VECTOR
__interrupt void PORT_1(void)
{
P1OUT ^= BIT0;//P1.0状态翻转
P1IFG &= ~BIT3;//中断标志位清零
}
|