BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Bootstrapping a New Platform: Basic LPM

This program disables the watchdog, configures for LPM, then enters LPM, bypassing all BSP430 initialization code. As an exception, if requested the board will flash the first two LEDs for a few seconds when it starts, to confirm that the application board is running.

If everything goes right, you can measure the board power consumption and compare that to what's on the data sheet. It's likely that you'll have to remove jumpers and/or disconnect any USB or RS232 connection in order to get power consumption all the way down to where it needs to be. Some platform-specific notes:

EXP430-G2

LaunchPad board revisions prior to 1.5 cannot achieve the lowest power mode without hardware modifications. To do the best you can, remove the TXD, RXD, and TEST jumpers connecting the emulation side of the board from the EXP430G2 side of the board (you can leave or remove RST). Measure the current across the Vcc jumper using an ammeter. The lowest current measurement you are likely to see is 76 uA in LPM4 when powering from the emulation USB port.

If you completely disconnect the emulation side and power from battery, you can get down to 65 uA on this revision of the hardware.

If you have revision 1.5 of the hardware, following the same process should get you around 0.1 uA with LPM4. The TXD/RXD and TEST jumpers may be left in place, but RST and VCC should be removed.

Compile-time Configuration

Note that this example includes infrastructure that allows configuring the build through the command line. For example, to enter LPM mode 2 with the LED notification, use the following as your build command:

make LPM=2 LED=1 realclean install

By default, LEDs are disabled and LPM4 will be entered.

main.c

#include <bsp430/clock.h>
#include <bsp430/lpm.h>
static const unsigned int lpm_bits[] = {
};
void main ()
{
WDTCTL = WDTPW | WDTHOLD;
#if (BSP430_LED - 0)
{
int i;
for (i = 0; i < 20; ++i) {
vBSP430ledSet(0, -1);
vBSP430ledSet(1, -1);
__delay_cycles(BSP430_CLOCK_PUC_MCLK_HZ / 10);
}
/* The subsequent vBSP430lpmConfigurePortsForLPM_ni() call should
* turn off the LED that's still lit. */
}
#endif
__delay_cycles(BSP430_CLOCK_PUC_MCLK_HZ);
while (1) {
#if (0 <= APP_LPM) && (APP_LPM <= 4)
BSP430_CORE_LPM_ENTER_NI(lpm_bits[APP_LPM]);
/* For this application it doesn't matter that GIE is now set */
#endif
}
}

bsp430_config.h

/* No console, no uptime, no crystal. Will not invoke platform
* initialize, so no need to configure those. The only thing needed
* is to specify the target LPM mode. */
#ifndef APP_LPM
#define APP_LPM 4
#endif /* APP_LPM */
/* Get platform defaults */

Makefile

LPM ?= 4
LED ?= 0
AUX_CPPFLAGS += -DAPP_LPM=$(LPM) -DconfigBSP430_LED=$(LED)
PLATFORM ?= exp430fr5739
MODULES=$(MODULES_PLATFORM)
MODULES += lpm
SRC=main.c
include $(BSP430_ROOT)/make/Makefile.common