// Olimex 1121-STK Demonstration Program
// Copyright (c) 2002, 2003 Rowley Associates Limited
//
// Toggles the LED attached to P2.3 and P2.4 on the 1121-STK under interrupt
// control.

#include <msp430x11x1.h>

  .code
  
reset:
   mov.w #0x210, sp
   mov.w #WDTPW + WDTHOLD, &WDTCTL   // Stop watchdog.
   mov.w #TASSEL0+TACLR, &TACTL      // Drive off ACLK.
   mov.w #CCIE, &CCTL0               // Enable CCR0 interrupt.
   mov.w #16384, &CCR0               // Set timer value.
   bis.w #0x18, &P2DIR               // P2.3,4 set to output.
   mov.w #0x10, &P2OUT               // Initial LED state.
   bis.w #MC1, &TACTL                // Start Timer_A in continuous mode.
   eint
L0 bis.w #CPUOFF, sr                 // Put the CPU into a comatose state.
   jmp L0

timera_isr:
   xor.b #0x18, &P2OUT               // Toggle LEDs
   add.w #16384, &CCR0               // Schedule next interrupt.
   reti

   .vectors
   .keep
   org  TIMERA0_VECTOR
   dw   timera_isr
   org  RESET_VECTOR
   dw   reset

