
Setup
Example code
Once loaded into the MSP430 of the LaunchPad, the code presented in this section performs the following
features:
•
At power on, the green LED present on the LaunchPad is turned on and turned off.
•
When the MSP430 receives a RSTn, the red LED is toggled 5 times, then the green LED is turned ON
and OFF and the MSP430 sends a DONE signal to the TPL5010.
•
When the MSP430 receives a WAKE pulse, the green LED is turned ON and OFF and the MSP430
sends a DONE signal to the TPL5010.
#include <msp430.h>
void main(void) {
WDTCTL = WDTPW | WDTHOLD;
// Stop watchdog timer
P1DIR |= BIT0;
// Set P1.0 to output direction
P2DIR |= BIT3;
// Set P2.3 to output direction
P4DIR |= BIT7;
// Set P4.7 to output direction
P1OUT &= ~BIT0;
// Set P1.0 RED LED OFF
P2OUT &= ~BIT3;
// Set P2.3 DONE Low
P4OUT &= ~BIT7;
// Set P4.7 GREEN LED OFF
P2IES &= ~BIT0;
// P2.0 Lo/Hi edge
P2IFG &= ~BIT0;
// P2.0 IFG Cleared
P2IE
|= BIT0;
// P2.0 Interrupt Enabled
SFRRPCR |= SYSNMIIES | SYSNMI;
// Select NMI function for the RST/NMI pin,
// interrupt on falling edge
// (pull-up R on RST/NMI is already enabled after PUC)
SFRIE1 |= NMIIE;
// Set NMI pin interrupt enable
P4OUT |= BIT7;
// Set P4.7 GREEN LED ON
__delay_cycles(500000);
// Set Delay
P4OUT &= ~BIT7;
// Set P4.7 GREEN LED OFF
P2OUT |= BIT3;
// Done High
__delay_cycles(100);
// Set Delay
P2OUT &= ~BIT3;
// Done Low
__bis_SR_register(LPM GIE);
// Enter LPM4
}
// Port 2 interrupt service routine
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
volatile unsigned int i;
P4OUT |= BIT7;
// GREEN LED ON
i = 10000;
// SW Delay
do i--;
while(i != 0);
P4OUT &= ~BIT7;
// Set P4.7 GREEN LED OFF
P2OUT |= BIT3;
// Done High
__delay_cycles(100);
// Set Delay
P2OUT &= ~BIT3;
// Done Low
P2IES &= ~BIT0;
// P2.0 Lo/Hi edge
P2IFG &= ~BIT0;
// P2.0 IFG Cleared
P2IE
|= BIT0;
// P2.0 Interrupt Enabled
9
SNAU173 – January 2015
TPL5010 Evaluation Module
Copyright © 2015, Texas Instruments Incorporated