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.

LP-MSP430FR2476: LP-MSP430FR2476, operation when connected via USB

Part Number: LP-MSP430FR2476

#include "driverlib.h"

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

    //Set LED1 to output direction
    GPIO_setAsOutputPin(GPIO_PORT_P5,GPIO_PIN0);
    GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);

    //Enable S1 internal resistance as pull-Up resistance
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2,GPIO_PIN3);

    //S1 interrupt enabled
    GPIO_enableInterrupt(GPIO_PORT_P2,GPIO_PIN3);

    //S1 Hi/Lo edge
    GPIO_selectInterruptEdge(
            GPIO_PORT_P2,GPIO_PIN3,
        GPIO_HIGH_TO_LOW_TRANSITION
        );


    //S1 IFG cleared
    GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN3);

    PMM_unlockLPM5();

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

    //For debugger
    __no_operation();
}


//******************************************************************************
//
//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)
{
    //LED1 = toggle
    GPIO_toggleOutputOnPin(GPIO_PORT_P5,GPIO_PIN0
        );

    //S1 IFG cleared
    GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN3
        );
}

When debugging the above program on the evaluation board,
Click “Resume”
The LED (green) lights up because it is set as GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);.
After that, when I input P2.3, it toggles, but
After debugging, when I unplug the USB and reconnect it, the LED (green) does not light up. If you input P2.3, the torge will be activated.
When you connect the USB and supply power,
I think that GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0); is set and the LED lights up.
Why doesn't it light up?
By the way, setting GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0); will do the opposite. (LED lights up when connected via USB)

  • To summarize briefly:
    If you set GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);, the LED will not light up when connected to USB.
    When you input P2.3, the LED turns ON/OFF, so the program is working.
    If you set GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0);, the LED will light up when connected to USB.
    When you input P2.3, the LED turns ON/OFF, so the program is working.

    After Debug, when you "Resume",
    When set as GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);, the LED lights up. When set as GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0);, the LED does not light up.

    After debugging, I think that the behavior is correct when I select "Resume" and the behavior is incorrect when connected to USB.Why does this happen?

  • User Guide (SLAU445I) Sec 8.3.1 prescribes an ordering for initialization of the registers. In particular, it says to clear IFG and set IE after clearing LOCKLPM5.

    When I forget this, I sometimes see inconsistent behavior, but since that's operating outside the Specification, it isn't described anywhere. Part of it may be the difference between a POR and a debugger reset (which seems to resemble more a PUC).

  • PMM_unlockLPM5();

    GPIO_clearInterrupt(GPIO_PORT_P2,GPIO_PIN3)

    GPIO_enableInterrupt(GPIO_PORT_P2,GPIO_PIN3)

    Should I write the code in the order above?

  • Yes, that looks right.

**Attention** This is a public forum