#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)