源码如下:
#include <msp430x14x.h>
void main( void )
{
P1DIR = 0Xff;P1OUT = 0Xff;
P2DIR = 0XFF;P2OUT = 0XFF;
P3DIR = 0XFF;P3OUT = 0XFF;
P4DIR = 0XFF;P4OUT = 0XFF;
P5DIR = 0XFF;P5OUT = 0XFF;
P6DIR = 0XFF;P6OUT = 0Xff;
WDTCTL = WDTPW + WDTHOLD; //关闭看门狗
P1IES = 0x0f; // P1.0~P1.3选择下降沿中断
P1IE = 0x0f; // 打开中断使能
P1DIR =0x00; //设置P1.0~P.3为输入状态,P.7为输出
P1OUT = 0;
_EINT(); //打开全局中断控制位
while(1);
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
unsigned int tmp;
P2OUT=0x00;
for(tmp = 12000;tmp > 0;tmp--);
P1IFG=0;
} |