//第16脚是RST/NMI/SBWTDIO在本程序中,如果按下RESER键,会进入非可屏蔽中断,使P10 led闪烁
#include
void main(void)
{
WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES;// WDT off NMI hi/lo
//WDTHOLD停止看门狗定时器WDTNMI选择RST/NMI pin为NMI功能WDTNMIES选择下降沿触发NMI
P1DIR |= 0x01;// Set P1.0 to output direction
P1OUT &= ~0x01;// Clear P1.0 LED off
IE1 |= NMIIE;// Enable NMI不可屏蔽中断使能
_BIS_SR(LPM0_bits);// Enter LPM0因为是非可屏蔽中断,所以不用打开总中断
}
#pragma vector=NMI_VECTOR
__interrupt void nmi_ (void)
{
volatile unsigned int i;
P1OUT |= 0x01;// Set P1.0 LED on
for (i = 20000; i > 0; i--);// Delay
P1OUT &= ~0x01;// Clear P1.0 LED off
IFG1 &= ~NMIIFG;// Reclear NMI flag in case bounce
//NMI中断标志位必须要软件清除
IE1 |= NMIIE;// Enable NMI
//当非可屏蔽中断被相应,所有的NMI使能位都会自动地被复位,所以NMI相应之后,用户必须软件重新使能需要的NMI
}