You are on page 1of 16

MSP-EXP430G2

LaunchPad Workshop
• Meet the LaunchPad
• Lab 1 : Blink LaunchPad LEDs

By Adrian Fernandez
Meet the LaunchPad
MSP430 MCU Value Line LaunchPad – only $4.30
A look inside the box
Complete LaunchPad kit includes:
• LaunchPad development board
• Mini-USB cable
• 2x MSP430 Value Line MCUs
• MSP430G2211
• MSP430G2231
• 10-pin PCB connectors/headers
• Free downloadable, code-limited IDEs
• Code Composer Studio
• IAR Embedded Workbench
• QuickStart Guide
• 2x LaunchPad stickers
Watch unboxing Watch pre-loaded demo

Watch videos on Youtube! 


(internet connection required)

http://www.youtube.com http://www.youtube.com/
/watch?v=RVHGjgkFPlU watch?v=U0mGoRtYbyg

3
MSP430 MCU Value Line LaunchPad – only $4.30
LaunchPad board

Get started in minutes


• Integrated Flash
emulation tool
• USB-powered (cable incl.)
• Program any MSP430 Value
Line device, eZ430 target
board, or Spy Bi-Wire
enabled MSP430 device
Easily evaluate &

Value Line
program devices
MSP430 Rapid Prototyping
• Up to 20-pin DIP
socketed target board • Access to all MSP430
• Drop-in any MSP430 Value Line pins
Value Line device • Easy interface for external
• Pre-programmed components/daughter
MSP430 Value Line boards
MCU included • 2 Programmable
pushbuttons & LEDs
Lab 1 : Blink LaunchPad’s LEDs

• Understand pin outs of LaunchPad


• Learn where to find free IDEs and design resources
• Develop code to blink LaunchPad’s red and green
on-board LEDs
MSP430 Ultra-Low Power MCUs
Understanding LaunchPad pinouts

On-board features of LaunchPad are


pinned in the following fashion:
– LED1 (red) = P1.0
– LED2 (green) = P1.6
– Switch1 = P1.3
– Switch2 = Reset
– Timer UART Transmit = P1.1
– Timer UART Receive = P1.2

Now we understand LaunchPad’s pin out!

In order to blink the Red and Green LEDs, we have to set Ports 1.0 and 1.6
as outputs, and toggle them in our project’s code.
MSP430 Ultra-Low Power MCUs
Step 1 – Download and Install CCS
1. Go to www.ti.com/launchpadwiki - #1 source for all content related to
LaunchPad
2. If not already on your PC, download and install CCS ver 4 to your PC
from the LaunchPad wiki
3. Once installed, open CCS version 4
4. When opened, you will be prompted to create a new “Workspace” –
This can be named anything you want! In our example, we named
ours “LaunchPadWork”
5. Then press OK…

6. This will create a new workspace for our first LaunchPad project!
MSP430 Ultra-Low Power MCUs
Step 2 – Set up CCS project
1. Once our workspace is generated, we will create
a new project
– File  New  CCS Project

2. Next, we need to name the project – we’ll call it


“LaunchPadLED”. Then, click “Next”

3. In the next window, we’ll be asked to Slect a type


of project. Since we are programming an MSP430
Value Line device, we choose “MSP430” from the
drop down list. Then, click “Next”
MSP430 Ultra-Low Power MCUs
Step 2 – Set up CCS project continued
4. In the next window, we won’t need any additional
project settings, so we can just click “Next”

5. Now, we need to select which “Device Variant” we


are going to program. For this simple LED blinking
example, any MSP430 Value Line device can be
used. In this case, this example was developed
using the MSP430G2231 device.

6. Once the appropriate device variant is highlighted,


we can click “Finish”

7. Now that the project settings are configured, we


need to add a new source file by right clicking our
active project and clicking New  Source File.
MSP430 Ultra-Low Power MCUs
Step 3 – Find MSP430 code examples
8. We will name this new source file “main.c” then
click “Finish” – At this point, a blank window will
be created. This is where our code will go.

9. Great! Our project area is all set up!

10. Next, we will learn where to find MSP430 Value


Line related code examples.

11. We need to go back to www.ti.com/launchpadwiki

12. In the wiki, we will find a link to “Download all


MSP430G2xx code examples”. Click it to
download a .zip file with all Value Line code
snippets.
MSP430 Ultra-Low Power MCUs
Step 4 – Import code example to project
13. Within this zip file, we will find assembly and C
code examples – we’ll use C for this lab. Within
the C folder are various code examples for getting
started with MSP430 Value Line devices.
– Each .c or assembly file within the zip has a description
and simple block diagram to explain its specific
functionality.

14. We will use msp430x20x3_1.c in for this example.


We can double click it to open the .c file. This
code example uses a software toggle to blink port
1.0 (which is tied to LED1, LaunchPad’s red LED)

15. Now, we can copy and paste this code into our
empty main.c that we created in CCS!
MSP430 Ultra-Low Power MCUs
Step 5 – Modify code example
16. Since the code example only toggles P1.0, only LED1 (red) will blink if
we leave the code as is. Thus, we need to modify it to also toggle P1.6
as well.

17. To do this, we first need to set P1.6 as an output port. To do this, we


need to set the direction bit of P1.6 as ‘1’ – This is done by adding the
highlighted line of code shown above.
MSP430 Ultra-Low Power MCUs
Step 6 – Modify code example continued
18. Now that Port 1.6 is set as an output, we can now toggle it in software,
which will cause it to blink. This is done by toggling the port within a for
loop, which will turn it off and on periodically. Similar to P1.0, P1.6 will
be toggled using “exclusive-OR” logic. The highlighted line below
accomplishes this.

19. Also, notice that this for loop will loop forever. The frequency of
blinking is controlled by the variable ‘i’, which causes a delay using a
“do-while” loop… The larger the number, the longer the delay between
toggles. We can experiment with different values to see its effects.
MSP430 Ultra-Low Power MCUs
Step 7 – Download code to LaunchPad
20. Great! We have made all the changes needed to blink both LEDs on
the LaunchPad board. We can now download this code to the
MSP430 Value Line device plugged into LaunchPad’s DIP target
socket. First, make sure LaunchPad is plugged in to your PC!

21. Next, we can click this “Debug” button, which will check the code and
load it into the MSP430 device.

22. When the code successfully loads, we will enter the Debug view of
CCS. We can execute the code by clicking the green “Run” arrow. At
this point, our red and green LEDs on the LaunchPad board should
start blinking!

23. Congratulations! You just completed your first LaunchPad project!


MSP430 Ultra-Low Power MCUs
Great! Now what???
• Now that you understand the pinouts of LaunchPad, discovered where to
find code examples, and successfully created your very first LaunchPad
project, you are well on your way to becoming an MSP430 master!

• Continue to explore www.ti.com/launchpadwiki to find more code


examples, projects, and other resources! This page is updated frequently,
and includes an active online community!

• Please feel free to contribute your own project ideas to the wiki pages as
well!

• Thank you, and happy coding from the MSP430 team in Dallas, TX ☺
MSP-EXP430G2
LaunchPad Workshop
Thank you!

You might also like