Learning About the Texas Instruments LaunchPad

Previous Main Up Next

Exercise Two

Workshop Exercise Two
Workshop Exercise Two

Exercise Two uses the IAR Embedded Workbench application to view the source code for the temperature demo and program the demo into the MSP430.

Close the temperature application and other open windows.

For the workshop participants, IAR Embedded Workbench was already installed on the provided laptops. For those reading this web page version who did not install this development environment during Exercise one, skip ahead to the extra notes and install the application.

We installed the "kickstart" version of IAR embedded workbench on each computer. This is a free version which doesn't expire but the compiled size of code is limited to 4k and it does not include features to support MISRA (Motor Industry Software Reliability Association). For all of your initial projects this will be fine. The installer can be found at http://www.ti.com/lit/zip/slac050.

The temperature demo MSP430 project is part of the user experience download which included the GUI used in Exercise One. If you skipped that step, you'll need to fetch that zip file from slac435.

Open the folder "slac435c\MSP-EXP430G2-Launchpad User Experience\src\MSP-EXP430G2-LaunchPad\IAR". Double-click on the "workspace.eww" file. If your IAR environment is installed correctly this action should launch IAR Workbench. If not, open IAR Workbench from the Windows start menu and open this workspace.

This should be what you see:

Initial IDE View
Initial IDE View

The open (and only) project in this workspace is the temperature demo. Scroll down the file view pane past the blue comments and you'll see the source code in C. The editor has a lot of features to help you out, such as syntax highlighting, lookup, help. It comes with a great help utility.

A quick review of basic comp sci. Why do we need a compiler. Source code ("main.c") is for humans. Computers need native instructions (machine code). They also need memory placement, byte ordering, byte alignment, and more. Compilers handle this translation. The IAR Workbench application includes the compiler.

Scroll down and look quickly at the source code. Delay walking through the code or discussing any features until Exercise Three.

Temperature Demo Code
Source Code File Web page view for printing

Building and Loading for the MSP430

Every time you make any changes to the code you'll need to follow these general steps:

You should not have any changes, but if you did you would use "File", then "Save All" from the IAR Workbench menu.

To build or rebuild your project, select "Project" then "Rebuild All" from the IAR Workbench menu. You should see messages during compile process in the lower pane. This should finish with no errors and no warnings.

Programming chips is complicated, which is why this board is so great. It makes downloading code to the chip easy and inexpensive. Other programmers are hundreds of dollars and come with a lot of features basic users don't need.

Connect your LaunchPad to your computer. Select "Project", "Download", then "Download Active Application". You should see debug log messages, then "Download Complete", "Target reset", and no errors.

If you receive an error that the device does not match then you will need to change the device, rebuild, and download again. The error will cause a pop up window which states "Chosen derivative (MSP430....) and actual hardware (MSP430G2xx3) do not match. Continue to download?". To correct this error you will need to change the target device in the project options. This is covered in Exercise Three.

Reset your chip by pressng the "RESET" button (right button) on your LaunchPad and it should work just like before. Try this out by running the temperature demo application on your computer from Exercise One again.

On to the third exercise - creating and then loading our own code into the chip.

Previous Main Up Next