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.

MSP430FR2433: Port 1 Interrupt problem: JMP __TI_ISR_TRAP

Part Number: MSP430FR2433

I am currently developing a door magnetic switch using msp430fr2433.(Environment: CCS10.4.0)

Firstly, I tried to use driverlib to speed up my development. As two buttons on launchpad are linked to P2.3 and P2.7, the example code run well last week and I thought it was simple.

However, there is another button linked to P1.1 on my own hardware. I tried to modify code like this.

void main (void)
{
    //Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    //Set LED to output direction
    GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);

    //Set LED pins HI
    GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);

    //Enable S1,S2 internal resistance as pull-Up resistance
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1,GPIO_PIN5);
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);

    //S1,S2 interrupt enabled
    GPIO_enableInterrupt(GPIO_PORT_P1,GPIO_PIN5);
    GPIO_enableInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);

    //S1 Hi/Lo edge
    GPIO_selectInterruptEdge(GPIO_PORT_P1,GPIO_PIN5,GPIO_HIGH_TO_LOW_TRANSITION);
    GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7,GPIO_HIGH_TO_LOW_TRANSITION);


    //S1 IFG cleared
    GPIO_clearInterrupt(GPIO_PORT_P1,GPIO_PIN5);
    GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);

    PMM_unlockLPM5();

    //Enter LPM3 w/interrupt
    __bis_SR_register(LPM3_bits + GIE);

    //For debugger
    __no_operation();
}

#if GPIO_PORT_S1 == GPIO_PORT_P1
//******************************************************************************
//
//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 P1_ISR (void)
{
    __delay_cycles(10000);
    GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
    GPIO_clearInterrupt(GPIO_PORT_P1,GPIO_PIN5);
}
#elif GPIO_PORT_S1 == GPIO_PORT_P2
//******************************************************************************
//
//This is the PORT2_VECTOR interrupt vector service routine
//
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT2_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(PORT2_VECTOR)))
#endif
void P2_ISR (void)
#endif // #if GPIO_PORT_S1
{
    __delay_cycles(10000);
    if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN2))
    {
        GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
        if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN2))
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2,GPIO_HIGH_TO_LOW_TRANSITION);
        }
        else
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2,GPIO_LOW_TO_HIGH_TRANSITION);
        }
    }

    if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN3))
    {
        GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0);
        if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN3))
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN3,GPIO_HIGH_TO_LOW_TRANSITION);
        }
        else
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN3,GPIO_LOW_TO_HIGH_TRANSITION);
        }
    }

    if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN7))
    {
        GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN1);
        if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN7))
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN7,GPIO_HIGH_TO_LOW_TRANSITION);
        }
        else
        {
            GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN7,GPIO_LOW_TO_HIGH_TRANSITION);
        }
    }

    GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3+GPIO_PIN7);
}

I downloaded this code to my launchpad. Two new buttons: P2.2 and P1.5, I used DuPont cable to short them to GND instead of pressing buttons.

Then some problem occured. The code doesn't run well and in debug view, the code stopped at JMP __TI_ISR_TRAP in isr_tram.asm

I just press start and suspend in the debug view and didn't press any button on my hardware.

I tried again to the original example and it seems to the same problem.

I also tried the example without driverlib: msp430fr243x_P1_03.c but failed just the same.

I'm confused why this happened and I'm sure there's nothing happened to my computer this weekend.

  • Hi Lucheni,

    Could you run step by step and see where the code run to? I see you add to much delay in your ISR. Could you try to decrease the delay_cycles ?

  • > #elif GPIO_PORT_S1 == GPIO_PORT_P2

    This causes the compiler to generate either the PORT1_VECTOR or the PORT2_VECTOR, but (as coded) you need both of them. 

    I recommend you remove all the GPIO_PORT_S1 checks, so you get two ISRs.

  • By viewing other posts, I tried to use DuPont cable shortcut 5v and GND to let the board fully discharge. (launchpad unconnected with the computer)

    Every time debugging after discharge the bord, it could run step by step to: __bis_SR_register(LPM3_bits + GIE);

    When I press the three buttons connected to PORT 2, it still works correctly.

    Just when I try to shortcut Gnd to P1.5(just like pressing a button connect to P1.5) the code run away to: JMP __TI_ISR_TRAP.

    The delay_cycles in code ISR is used for key debounce, cause there is no debounce capacitor on launchpad

  • I tried to change the example code(version without driverlib)

    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        // Configure GPIO
        P1OUT &= ~BIT0;                         // Clear P1.0 output latch for a defined power-on state
        P1DIR |= BIT0;                          // Set P1.0 to output direction
        P2OUT &= ~(BIT3+BIT7);
        P2DIR |= BIT3+BIT7;
    
        P1OUT |= BIT3;                          // Configure P1.3 as pulled-up
        P1REN |= BIT3;                          // P1.3 pull-up register enable
        P1IES |= BIT3;                          // P1.3 Hi/Low edge
        P1IE |= BIT3;                           // P1.3 interrupt enabled
        P2OUT |= BIT3+BIT7;                     // Configure P2.3&P2.7 as pulled-up
        P2REN |= BIT3+BIT7;                     // P2.3&P2.7 pull-up register enable
        P2IES |= BIT3+BIT7;                     // P2.3&P2.7 Hi/Low edge
        P2IE |= BIT3+BIT7;                      // P2.3&P2.7 interrupt enabled
    
        // Disable the GPIO power-on default high-impedance mode
        // to activate previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        P1IFG &= ~BIT3;                         // P1.3 IFG cleared
        P2IFG &= ~(BIT3+BIT7);
    
        while(1)
        {
            __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/interrupt
            __no_operation();                   // For debug
            P1OUT ^= BIT0;                      // P1.0 = toggle
        }
    }
    
    // Port 1 interrupt service routine
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    {
        P1IFG &= ~BIT3;                         // Clear P1.3 IFG
        __bic_SR_register_on_exit(LPM3_bits);   // Exit LPM3
    }
    
    // Port 2 interrupt service routine
    #pragma vector=PORT2_VECTOR
    __interrupt void Port_2(void)
    {
        P2IFG &= ~(BIT3+BIT7);                         // Clear P1.3 IFG
        __bic_SR_register_on_exit(LPM3_bits);   // Exit LPM3
    }
    

    This code seems run well now.

    Then I tried to change the example code(version with driverlib)

    #include "driverlib.h"
    #include "Board.h"
    
    void main (void)
    {
        //Stop watchdog timer
        WDT_A_hold(WDT_A_BASE);
    
        //Set LED to output direction
        GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
    
        //Set LED pins HI
        GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
    
        //Enable S1,S2 internal resistance as pull-Up resistance
        GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1,GPIO_PIN5);
        GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);
    
        //S1,S2 interrupt enabled
        GPIO_enableInterrupt(GPIO_PORT_P1,GPIO_PIN5);
        GPIO_enableInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);
    
        //S1 Hi/Lo edge
        GPIO_selectInterruptEdge(GPIO_PORT_P1,GPIO_PIN5,GPIO_HIGH_TO_LOW_TRANSITION);
        GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7,GPIO_HIGH_TO_LOW_TRANSITION);
    
    
        //S1 IFG cleared
        GPIO_clearInterrupt(GPIO_PORT_P1,GPIO_PIN5);
        GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3 + GPIO_PIN7);
    
        PMM_unlockLPM5();
    
        //Enter LPM3 w/interrupt
        __bis_SR_register(LPM3_bits + GIE);
    
        //For debugger
        __no_operation();
    }
    
    //******************************************************************************
    //
    //This is the PORT1_VECTOR interrupt vector service routine
    //
    //******************************************************************************
    #pragma vector=PORT1_VECTOR
    void P1_ISR (void)
    {
        __delay_cycles(10000);
        GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
        GPIO_clearInterrupt(GPIO_PORT_P1,GPIO_PIN5);
    }
    //******************************************************************************
    //
    //This is the PORT2_VECTOR interrupt vector service routine
    //
    //******************************************************************************
    #pragma vector=PORT2_VECTOR
    void P2_ISR (void)
    {
        __delay_cycles(10000);
        if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN2))
        {
            GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0 + GPIO_PIN1);
            if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN2))
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2,GPIO_HIGH_TO_LOW_TRANSITION);
            }
            else
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN2,GPIO_LOW_TO_HIGH_TRANSITION);
            }
        }
    
        if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN3))
        {
            GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0);
            if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN3))
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN3,GPIO_HIGH_TO_LOW_TRANSITION);
            }
            else
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN3,GPIO_LOW_TO_HIGH_TRANSITION);
            }
        }
    
        if (GPIO_getInterruptStatus(GPIO_PORT_P2 , GPIO_PIN7))
        {
            GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN1);
            if (GPIO_INPUT_PIN_HIGH == GPIO_getInputPinValue(GPIO_PORT_P2 , GPIO_PIN7))
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN7,GPIO_HIGH_TO_LOW_TRANSITION);
            }
            else
            {
                GPIO_selectInterruptEdge(GPIO_PORT_P2,GPIO_PIN7,GPIO_LOW_TO_HIGH_TRANSITION);
            }
        }
    
        GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN2 + GPIO_PIN3+GPIO_PIN7);
    }
    

    Some old problem occured. This situation happened last week, but it could not be repeated yesterday, so it was not sent out.

    The code can be debugged step by step till:_ _bis_SR_register(LPM3_bits + GIE);

    But when I press the button, it just happens.

  • > void P1_ISR (void)

    This should be:

    > __interrupt void P1_ISR (void)

    --------

    Similarly for P2_ISR()

    --------

    Unsolicited: To enable a pin interrupt you should (1) Set IES (2) Clear IFG (3) Set IE. You can do (1) before clearing LOCKLPM5, but you have to do (2)/(3) after. The symptom would be spurious interrupts rather than a crash.

  • It works right now.

    Thanks for the explanation.

**Attention** This is a public forum