Quantcast
Channel: MSP 低功耗微控制器论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 3634

MSP430 FR2033IO中断无法进入

$
0
0

在使用430IO口中断的时候发现无法进入中断,代码是这样的:

#define LED_CHARGE_INIT do{P2DIR |= BIT6;}while(0)
#define LED_CHARGE_ON do{P2OUT |= BIT6;}while(0)
#define LED_CHARGE_OFF do{P2OUT &= ~BIT6;}while(0)

#define USB_IN_INIT do{ \
P1SEL0 &= ~BIT4; /* io function */ \
P1DIR &= ~BIT4; /* input */ \
P1REN |= BIT4; /* internal pull enable */ \
P1OUT &= ~BIT4; /* pull down inside */ \
P1IES &= ~BIT4; /* raise edge interrupt */ \
}while(0)
#define USB_IN_IRQ_EN do{ \
P1IFG &= ~BIT4; /* clear interrupt */ \
P1IE |= BIT4; /* enable interrupt */ \
}while(0)
#define USB_IN_IRQ_DIS do{ \
P1IFG &= ~BIT4; /* clear interrupt */ \
P1IE &= ~BIT4; /* disable interrupt */ \
}while(0)


#define CHARGE_IN_INIT do{ \
P1SEL0 &= ~BIT2; /* io function */ \
P1DIR &= ~BIT2; /* input */ \
P1REN |= BIT2; /* internal pull enable */ \
P1OUT |= BIT2; /* pull up inside */ \
P1IES |= BIT2; /* fall edge interrupt */ \
}while(0)
#define CHARGE_IN_IRQ_EN do{ \
P1IFG &= ~BIT2; /* clear interrupt */ \
P1IE |= BIT2; /* enable interrupt */ \
}while(0)
#define CHARGE_IN_IRQ_DIS do{ \
P1IFG &= ~BIT2; /* clear interrupt */ \
P1IE &= ~BIT2; /* disable interrupt */ \
}while(0)

#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
P7OUT |= BIT1;
switch(__even_in_range(P1IV,P1IV_P1IFG6))
{
case P1IV_NONE:break;
case P1IV_P1IFG0:break;
case P1IV_P1IFG1:break;
case P1IV_P1IFG2:
P1IFG &= ~BIT2;
LED_CHARGE_ON;
break;
case P1IV_P1IFG3:break;
case P1IV_P1IFG4:
USB_IN_IRQ_DIS;
P1IFG &= ~BIT4;
P1IES ^= BIT4;
if(P1IN & BIT4){
//LED_CHARGE_ON;
P7OUT |= BIT1;
}
else{
//LED_CHARGE_OFF;
P7OUT &= ~BIT1;
}
USB_IN_IRQ_EN;
break;
case P1IV_P1IFG5:break;
case P1IV_P1IFG6:
break;
default:break;
}
}

void main()

{

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
init_sclk();
init_gpio();

P7SEL0 &= ~BIT1;
P7DIR |= BIT1;
charge_init();
init_rtc();

LED_CHARGE_OFF;

P7OUT &= ~BIT1;

while(1){
__bis_SR_register(GIE);
}

}

P1.4为USB插入检测,当USB插入的时候该IO口电平变高,用查询模式去扫描该IO口电平时可以的,但是用中断方式就是进不去中断,P7.1接了一个LED灯,LED没有任何反应

请问我这段代码哪里有问题吗,我看了中断相关的寄存器,我都配了,就是没有进入中断


Viewing all articles
Browse latest Browse all 3634

Trending Articles