--- /dev/null
+MCU = msp430g2111
+CC = msp430-gcc
+CFLAGS=-Wall -g -Os -mmcu=$(MCU)
+LDFLAGS=
+
+main.elf: main.c
+ $(CC) $(CFLAGS) -o $@ $<
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+prog: program
+program: main.elf
+ MCU=$(MCU) mspdebug rf2500 "prog $<"
+
+clean:
+ rm -f main.elf
--- /dev/null
+#include <msp430.h>
+#include <legacymsp430.h>
+
+#define LED0 BIT0 /* P1.0 */
+
+static void
+init_leds(void)
+{
+ P1DIR |= LED0; /* set P1.0 as output */
+ P1OUT |= LED0; /* set P1.0 low */
+
+ /* set timer A to use the aux clock in UP mode with ACLK/8 divider */
+ TACTL = TASSEL_1 | MC_1 | ID_3;
+ /* set the counter to match on 511 which is 1s for 32kHz/8/8 (timer
+ * re-divides the interrupt clock by 8 */
+ TACCR0 = 511;
+ /* enable the clock interrupt mode for TACCR0 match */
+ TACCTL0 = CCIE;
+}
+
+int
+main(void)
+{
+ /* disable the watchdog */
+ WDTCTL = WDTPW + WDTHOLD;
+
+ /* external 32.768kHz crystal */
+ BCSCTL1 |= DIVA_3; /* ACLK/8 */
+ BCSCTL3 |= XCAP_3; /* enable 12.5pF internal capacitance */
+
+ init_leds();
+
+ /* enable global interrupts */
+ eint();
+
+ while (1) {
+ /* do nothing forever, timer interrupts drive the leds */
+ /* enter low power mode 3 with interrupts enabled) */
+ _BIS_SR(LPM3_bits + GIE);
+ }
+}
+
+interrupt(TIMER0_A0_VECTOR)
+TIMERA0_ISR(void)
+{
+ /* clear the interrupt flag and toggle LED */
+ TACCTL0 &= ~CCIFG;
+ P1OUT ^= LED0;
+}