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.

关于MSP430FR6972芯片IO中断问题的请教

Other Parts Discussed in Thread: MSP430FR6972

各位大神:

                  你们好,小弟现在在用MSP430FR6972芯片,在使用IO中断时,发现能进中断但是IO中断标志位却无法清除,请问是什么原因,求指教,小弟不胜感激!

void IO_Init()          //引脚初始化P4.6
{

    P4DIR &= ~BIT6; //输入引脚,连接IRQ1引脚
    P4IES &= ~BIT6; //上升沿触发
    P4IE |= BIT6; //开中断
    P4IFG &= ~BIT6; //清中断标志

}

#pragma vector=PORT4_VECTOR   //中断服务函数
__interrupt void PORT4 (void)
{

    P4IFG &= ~BIT6; //clear the interrupt flag   ,运行完此句P4.6的中断标志依然为1
}

请问问题出在哪里,是P4无法使用IO中断吗?谢谢大家!

  • 单步看的吗?

    这是P1.1做中断触发的例程,你试一下看看?

    #include <msp430.h>

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

    // Configure GPIO
    P1OUT = BIT1; // Pull-up resistor on P1.1
    P1REN = BIT1; // Select pull-up mode for P1.1
    P1DIR = 0xFF ^ BIT1; // Set all but P1.1 to output direction
    P1IES = BIT1; // P1.1 Hi/Lo edge
    P1IFG = 0; // Clear all P1 interrupt flags
    P1IE = BIT1; // P1.1 interrupt enabled

    P2OUT = 0;
    P2DIR = 0xFF;

    P3OUT = 0;
    P3DIR = 0xFF;

    P4OUT = 0;
    P4DIR = 0xFF;

    PJOUT = 0;
    PJDIR = 0xFFFF;

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

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

    // Port 1 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void)
    #else
    #error Compiler not supported!
    #endif
    {
    P1IES ^= BIT1; // Toggle interrupt edge
    P1IFG &= ~BIT1; // Clear P1.1 IFG
    __bic_SR_register_on_exit(LPM4_bits); // Exit LPM4
    }

  • 楼主你好,你是怎么观察的io中断标志位没清掉?

  • CHANG CHAO SHAO 说:

    各位大神:

                      你们好,小弟现在在用MSP430FR6972芯片,在使用IO中断时,发现能进中断但是IO中断标志位却无法清除,请问是什么原因,求指教,小弟不胜感激!

    void IO_Init()          //引脚初始化P4.6
    {

        P4DIR &= ~BIT6; //输入引脚,连接IRQ1引脚
        P4IES &= ~BIT6; //上升沿触发
        P4IE |= BIT6; //开中断
        P4IFG &= ~BIT6; //清中断标志

    }

    #pragma vector=PORT4_VECTOR   //中断服务函数
    __interrupt void PORT4 (void)
    {

        P4IFG &= ~BIT6; //clear the interrupt flag   ,运行完此句P4.6的中断标志依然为1
    }

    请问问题出在哪里,是P4无法使用IO中断吗?谢谢大家!

    代码里有没有这句话

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;
  • 铁电MCU在IO设置完成后,需要解锁IO口使之前设置生效,需加一句PM5CTL0 &= ~LOCKLPM5;另外,若上升沿触发中断,最好使能IO内部下拉。