This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于msp430fr5739外部中断

Other Parts Discussed in Thread: MSP-EXP430FR5739

【求详解】本人在使用fp5739的外部中断时发现问题,于是进行测试发现只有外部端口位1.4是才能正确中断,将此代码修改位其他端口均不正确(不是不中断就是一直自己在中短),请问这是我程序设计的问题么?我应该怎么解决

如下是p1.4的外部中断端口设置代码

#include <msp430.h>

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P1DIR |= BIT0; // Set P1.0 to output direction
P1OUT &= ~BIT0;

P1OUT &= ~BIT4; //
P1IES &= ~BIT4; // P1.4 Lo/Hi edge
P1IE = BIT4; // P1.4 interrupt enabled
P1IFG &= ~BIT4; // P1.4 IFG cleared

while(1)
{
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4 w/interrupt
__no_operation(); // For debugger
P1OUT ^= BIT0; // P1.0 = toggle
P1IE = BIT4;
}
}

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)

P1IFG &= ~BIT4; // Clear P1.4 IFG
P1IE = 0;
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM4
}

如下是p1.6的外部中断端口设置代码

#include <msp430.h>

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P1DIR |= BIT0; // Set P1.0 to output direction
P1OUT &= ~BIT0;

P1OUT &= ~BIT6; //
P1IES &= ~BIT6; // P1.6 Lo/Hi edge
P1IE = BIT6; // P1.6 interrupt enabled
P1IFG &= ~BIT6; // P1.6 IFG cleared

while(1)
{
__bis_SR_register(LPM4_bits + GIE); // Enter LPM6 w/interrupt
__no_operation(); // For debugger
P1OUT ^= BIT0; // P1.0 = toggle
P1IE = BIT6;
}
}

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1IFG &= ~BIT6; // Clear P1.6 IFG
P1IE = 0;
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM4 
}