MSP430 Tutorial

MSP430 code examples

/*
 * 
 *                       MSP430 CODE EXAMPLE DISCLAIMER
 *
 * MSP430 code examples are self-contained low-level programs that typically
 * demonstrate a single peripheral function or device feature in a highly
 * concise manner. For this the code may rely on the device's power-on default
 * register values and settings such as the clock configuration and care must
 * be taken when combining code from several examples to avoid potential side
 * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
 * for an API functional library-approach to peripheral configuration.
 *
 * --/COPYRIGHT--*/
//******************************************************************************
//   MSP430F552x Demo - Software Toggle P2.0, P2.2
//
//   Description: Toggle P2.0, P2.2 by xor'ing P2.0, P2.2 inside of a software loop.
//   ACLK = 32.768kHz, MCLK = SMCLK = default DCO~1MHz
//
//                MSP430F552x
//             -----------------
//         /|\|                 |
//          | |                 |
//          --|RST              |
//            |                 |
//            |             P2.0|-->LED
//			    P2.2|-->LED
//
//******************************************************************************
#include <msp430.h>

int main(void)
{
  volatile unsigned int i;

  WDTCTL = WDTPW+WDTHOLD;		// Stop WDT
  //P1DIR |= BIT0;			// P1.0 set as output
  P2DIR |= BIT0;			// P2.0 set as output
  P2DIR |= BIT2;			// P2.2 set as output
  while(1)				// continuous loop
  {
	//P1OUT ^= BIT0;                          // XOR P1.0
	P2OUT ^= BIT0;
	P2OUT ^= BIT2;
	for(i=50000;i>0;i--);                   // Delay
  }
}