程序如下所示,但单片机不能够进入外部中断,P1.1的外部中断标志位也一直为低,但P1.2的变为了1。
#include "msp430f449.h"
void delay(unsigned int z)
{
unsigned int x,y;
for(x=0;x<500;x++)
for(y=0;y<z;y++);
}
void PORT_Init()
{
P1DIR&=~BIT1; //The pin P1.1 is the signal input;
P1DIR|=BIT2; //The pin P1.2 is the signal output;
P1IES|=BIT1; //p1.1 rising edge trigger
P1IE|=BIT1; //p1.1 interrupt enable
P1IFG&=~BIT1; //P1.1 interrupt flag clear
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer
PORT_Init();
_EINT();
while(1)
{
}
}
#pragma vector=PORT1_VECTOR
__interrupt void port_1()
{
P1OUT^=BIT2;
delay(100);
} |