//******************************************************************************
//  MSP-FET430P140 Demo - Timer_B Toggle P1.0, overflow ISR, DCO SMCLK 
//
//  Description; Toggle P1.0 using using software and timer_B overflow ISR. 
//  In this example an ISR will trigger when TA overflows.  Inside the TB
//  overflow ISR P1.0 is toggled.  Toggle rate is approximatlely 12hz. 
//  MCLK = SMCLK = TACLK = DCO ~ 800k. 
//  Proper use of TBIV interrupt vector generator demonstrated.
//  
//           MSP430F149
//         ---------------
//     /|\|            XIN|-  
//      | |               |
//      --|RST        XOUT|-
//        |               |
//        |           P1.0|-->LED
//
//  M. Buccini
//  Texas Instruments, Inc
//  January 2002
//  Built with IAR Embedded Workbench Version: 1.25A
//******************************************************************************

#include <msp430x14x.h>

void main(void)
{ 
  WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
  TBCTL = TBSSEL1 + TBCLR + TBIE;       // SMCLK, clr. TBR, interrupt
  P1DIR |= 0x01;                        // Set P1.0 to output direction
  TBCTL |= MC1;                         // Start Timer_B in continous
  _EINT();                              // Enable interrupts
 
  for (;;)                              
  {
    _BIS_SR(CPUOFF);                    // CPU off
    _NOP();                             // Required only for C-spy
  }
}

// Timer_B7 Interrupt Vector (TBIV) handler
void Timer_B(void) __interrupt [TIMERB1_VECTOR] 
{
 switch( TBIV )
 {
   case  2: break;                      // CCR1 not used
   case  4: break;                      // CCR2 not used
   case 14: P1OUT ^= 0x01;              // overflow
            break;
 }
}

