Using Code Composer Studio

Open Code Composer Studio and open a new project File>New>CCS Project

The following Dialog will appear

New CCS Project

You need to:

  1. Enter a name for the project
  2. Select the device family (MSP430)
  3. Select the Variant (MSP430G2553)
  4. Choose an empty project with main.c

Then paste the following blink code within the main function

	P1DIR |= (1<<6)|(1<<0);			// Set P1.0 and P1.6 to output direction
	P1OUT |= (1<<6);				// Set P1.6 to on
	P1OUT &= ~(1<<0);				// Set P1.0 to off

	while(1) {						// infinite while loop (Keep doing the same operation forever)
		unsigned int i;

		P1OUT ^= (1<<6)|(1<<0);		// Toggle P1.0 and P1.6 using exclusive-OR

		i = 65535;					// Software Delay (2^16-1 is the maximum delay)
		while(i-- != 0);
	}

To compile and upload the code to the microprocessor first make sure that the MSP430 Launch pad is plugged into one of the USB ports of your computer.

Then click the Debug button (or F11). When compiled and uploaded you will then need to press the Resume button (or F8). The code should now run on the MSP430G2553 and the LEDs 1 and 2 should blink alternatively.

The complete code listing is below

/*
 * Alternate Blink for MSP430 Launchpad
 *
 * Benn Thomsen January 2013
 */
#include "msp430.h"
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer

	P1DIR |= (1<<6)|(1<<0);			// Set P1.0 and P1.6 to output direction
	P1OUT |= (1<<6);				// Set P1.6 to on
	P1OUT &= ~(1<<0);				// Set P1.0 to off

	while(1) {						// infinite while loop (Keep doing the same operation forever)
		unsigned int i;

		P1OUT ^= (1<<6)|(1<<0);		// Toggle P1.0 and P1.6 using exclusive-OR

		i = 65535;					// Software Delay (2^16-1 is the maximum delay)
		while(i-- != 0);
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s