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.

[参考译文] MSP430F5529:端口中断1:无法退出 ISR

Guru**** 2589300 points
Other Parts Discussed in Thread: MSP430F5529

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1111463/msp430f5529-port-interrupt-1-not-able-exit-form-the-isr

器件型号:MSP430F5529

大家好、

我是第一次基于 MSP430F5529开发应用

我遇到端口中断问题。 为了调试这个问题、我编写了一个简单的程序、如下所示。

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

    // SMCLK Source Divider f(SMCLK)/32
    UCSCTL5 |= DIVS__32;

    /* Timer-1 */
    // CCR0 interrupt enabled
    TA0CCTL0 = CCIE;
    TA0CCR0 = 32767;
    // SMCLK, Up-mode
    TA0CTL = TASSEL_2 + MC_1;

    // Set P1.0 to output direction
    P1DIR = 0x01;

    // Enable P1.1 internal resistance as pull-Up resistance
    P1OUT = 0x02;
    P1REN = 0x02;    

    // P1.1 Hi/Lo edge
    P1IES |= 0x02;

    /*
     * Disable the GPIO power-on default high-impedance mode to activate
     * previously configured port settings
     */
    PMM_unlockLPM5();

    // P1.1 IFG cleared
    P1IFG &= ~0x02;

    // P1.1 interrupt enabled
    P1IE |= 0x02;

    // Enter LPM4 w/interrupt
    __bis_SR_register(LPM4_bits + GIE);

    // For debugger
    __no_operation();
}

void watchdogtimer_init(void)
{

    WDTCTL = 0x5A05; /* WDTSSEL0 - 0x0000 --> Select Watchdog timer clock source as SMCLK
                        WDTIS2   - 0x0004 --> 2nd bit 1
                        WDTIS0   - 0x0001 --> 0th bit 1
                        WDTIS    - 101 - Select (250 ms at 32.768 kHz) as the watchdog timer interval to generate a PUC.  */
}

//******************************************************************************
//
// This is the PORT1_VECTOR interrupt vector service routine
//
//******************************************************************************
#pragma vector = PORT1_VECTOR
__interrupt void Port_1(void)
{

    P1OUT ^= 0x01;
}

在此代码中、我永远无法退出中断。 是否缺少任何配置友好支持  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Sankeertha、

    您可能希望在中断矢量期间尝试清除中断标志、以便中断不会持续执行。 您可能需要在 MSP430F5529部分的资源浏览器中查看、其中有一个名为 GPIO_ex2_inputCapture 的示例、您可能会发现该示例很有用。

    如果可以的话,请告诉我!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好  

    正如您提到的 、我清除 了 IFG。 请参阅以下代码

    int main(void)
    {
        // Stop watchdog timer
        WDTCTL = WDTPW + WDTHOLD;
    
        // Set P1.0 to output direction
        P1DIR = 0x01;
    
        // Enable P1.1 internal resistance as pull-Up resistance
        P1OUT = 0x02;
        P1REN = 0x02;
    
        // P1.1 interrupt enabled
        P1IE |= 0x02;
    
        // P1.1 Hi/Lo edge
        P1IES |= 0x02;
    
        // P1.1 IFG cleared
        P1IFG &= ~0x02;
    
        // Enter LPM4 w/interrupt
        __bis_SR_register(LPM4_bits + GIE);
    
        // For debugger
        __no_operation();
    }
    
    //******************************************************************************
    //
    // This is the PORT1_VECTOR interrupt vector service routine
    //
    //******************************************************************************
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = PORT1_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(PORT1_VECTOR)))
    #endif
        void
        Port_1(void)
    {
        // P1.0 = toggle
        P1OUT ^= 0x01;
    
        // P1.1 IFG cleared
        P1IFG &= ~0x02;
    }
    

    但这会导致以下问题。 如何解决?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Sankeertha、

    我继续使用您在这里发布的代码对我自己的 Launchpad 进行编程、该示例在我的末尾似乎运行良好、并且不会发生像您向我展示的那样的挂起。  

    下一步、我建议您尝试将我向您指出的示例加载到您的板上、以查看其加载是否正确。 您的代码可在我的 Launchpad 上运行这一事实表明、问题是除代码之外的其他问题导致了此问题。