0% found this document useful (0 votes)
18 views6 pages

Msp430 Manual

This document provides instructions for creating a project in Code Composer Studio to blink the red LED on an MSP430 LaunchPad board. It describes downloading and installing CCS software, creating a new project called "Blink_LED" for an MSP430G2553 device, writing code to initialize ports and toggle the LED in a forever loop, and debugging/running the code to make the LED blink.

Uploaded by

Twinkle Ratna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Msp430 Manual

This document provides instructions for creating a project in Code Composer Studio to blink the red LED on an MSP430 LaunchPad board. It describes downloading and installing CCS software, creating a new project called "Blink_LED" for an MSP430G2553 device, writing code to initialize ports and toggle the LED in a forever loop, and debugging/running the code to make the LED blink.

Uploaded by

Twinkle Ratna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

In this project, we will learn a few things:

How to create a new project with Code Composer Studio

Learn how to blink the on-board Red LED on the MSP430 LaunchPad

Change the speed of the blinking Red LED

Learn how to toggle between the Red and Green LED

Things you will need


1. MSP430 LaunchPad Evaluation Kit (MSP-EXP430G2)
2. Code Composer Studio (Software Development Environment)

Hardware setup
1. The MSP-EXP430G2 LaunchPad kit includes everything you need out of the box
2. To start programming, you'll first have to install CCS which contains the required drivers for
your new MSP-EXP430G2 LaunchPad kit
3. Plug your MSP-EXP430G2 LaunchPad into the PC with the included USB cable
4. If prompted, let Windows automatically install the software.

Create a new CCS workspace


1. Upon opening CCS, it will ask you to select a workspace
2. Since this is our first project, we'll create a new one called "LaunchPad_Projects". A
workspace is where all of your Code Composer Studio projects will live. Once created,
press OK

3. Once CCS is opened, we can create a new project by going to File > New > CCS Project

4. This will open up the "New CCS Project" Window. Within this window, we need to do 2
things. Name our project & choose our Device Variant. Let's name our project "Blink_LED"
We also need to choose the appropriate MSP430 device. For this tutorial, we will program
the MSP430G2553 device that comes pre-populated on the MSP430 LaunchPad. (Due to
the simplicity of this particular tutorial, any of the MSP430G2xx devices will work for this
example!) Then, click "Finish"

Writing code
Now, we have our blank canvas! We can finally start writing code!
1. #include <msp430g2553.h>
2.
3. unsigned int i = 0;
4.
5.
// Initialize variables. This will keep count of how many cycles
between LED toggles
6.
7.
8. void main(void)
9. {

10.
11.
12.
13.
14.

WDTCTL = WDTPW + WDTHOLD;


// Stop watchdog timer. This line of code is needed at the beginning
of most MSP430 projects.

// This line of code turns off the watchdog timer, which can reset the
device after a certain period of time.
15.
// P1DIR is a register that configures the direction (DIR) of a port
pin as an output or an input.
16.
17.
P1DIR |= 0x01;
18.
19.
20.
// To set a specific pin as output or input, we write a '1' or '0' on
the appropriate bit of the register.
21.
22.
23.
// P1DIR = <PIN7><PIN6><PIN5><PIN4><PIN3><PIN2><PIN1><PIN0>
24.
25.
26.
// Since we want to blink the on-board red LED, we want to set the
direction of Port 1, Pin 0 (P1.0) as an output
27.
28.
// We do that by writing a 1 on the PIN0 bit of the P1DIR register
29.
// P1DIR = <PIN7><PIN6><PIN5><PIN4><PIN3><PIN2><PIN1><PIN0>
30.
// P1DIR = 0000 0001
31.
// P1DIR = 0x01
<-- this is the hexadecimal conversion of 0000
0001
32.
33.
34.
35.
for (;;)
36.
37.
// This empty for-loop will cause the lines of code within to loop
infinitely
38.
39.
{
40.
41.
42.
43.
P1OUT ^= 0x01;
44.
45.
// Toggle P1.0 using exclusive-OR operation (^=)
46.
47.
// P1OUT is another register which holds the status of the LED.
48.
// '1' specifies that it's ON or HIGH, while '0' specifies that it's
OFF or LOW
49.
// Since our LED is tied to P1.0, we will toggle the 0 bit of the
P1OUT register
50.
51.
for(i=0; i< 20000; i++);
52.

53.

// Delay between LED toggles. This for-loop will run until the
condition is met.
54.
//In this case, it will loop until the variable i increments to 20000.
55.
}
56.
}

1. Now that we have written our code, we can download it to our MSP430 LaunchPad that is
plugged into the USB port! We can do this by clicking the debug button

2. Clicking the Debug button will take us to the CCS Debug View. Here, we can press the Run
button to start running the code we just wrote.

3. At this point, your Red LED should be blinking! Congratulations!

You might also like