Sunteți pe pagina 1din 4

EE 4390 Laboratory # 1

Introduction to the MSP-EXP430G2 LaunchPad and Energia


Purpose
In this lab, the student will gain first exposure to programming an MSP430G2xxx microcontroller on
the Texas Instruments MSP-EXP430G2 LaunchPad evaluation kit. The Energia integrated development
environment (IDE) is utilized to provide a C/C++ coding platform as well as a user-friendly interface
for uploading the application code into the microcontroller. The student will also begin to utilize the
benchtop oscilloscope and logic analyzer to observe and record the timing of events associated with the
microcontroller embedded application.

Background
According to the Energia website, http://energia.nu/faqs,. . .
Energia is an open-source electronics prototyping platform developed by Robert Wessels with
the goal to bring the Arduino and Wiring framework to the Texas Instruments MSP430 LaunchPad evaluation kit.
What this means to us is that we have inexpensive (free) access to a well-tested tool-chain (compiler, assembler, linker, uploader, debugger) for implementing embedded microcontroller solutions with the MSP430.
The Wiring (http://wiring.org.co) and Arduino (http://arduino.cc) software and hardware projects
form an excellent foundation for beginner through expert-level use. Extensive example projects and interface libraries make beginner-level implementation of even large systems quite achievable. In this class,
well first test the waters of system implementation at the beginner-level (this lab exercise) then plunge
deeply into the bowels of advanced to expert-level use of the excellent tool-chain that underlies Energia .
To download this software onto your personal computer, visit the Energia website and select appropriately
(implementations are available for Mac OS X, Windows and Linux). No download is required for most of
our course needs if you are working on campus (well introduce and demonstrate in class how to utilize
Energia from a networked drive for Windows machines). The most recent version of Energia available for
download is 16. The computing labs you will work with this semester have everything from version 11 to
16 available. You should see very little if any dierence across versions for our particular needs.
When you run the Energia IDE, the user-interface window you view by default should appear similar to
that shown in Figure 1.1. The file edit window presents an empty Sketch, which is simply a template
of the bare essential C++ functions that the designer must fill-in in order to describe their application
program. The conceptual framework for the implementation is the following:
(a) When the microcontroller powers up or responds to a system reset, all essential housekeeping initialization at the lowest levels is completed in a default manner.
(b) Next, the user-specified setup() function is called to complete application specific initialization.
(c) Finally, an infinite loop is entered wherein the user-specified loop() function is called forever (that
is, if the execution of loop() ends, it will be recalled almost immediately to again execute).
<Version: Fall 2015>

EE 4390 Laboratory Manual

Figure 1.1 The Default Screen for the Energia User-Interface

A large number of example Sketches can be accessed from the Energia File / Examples menu. Figure 1.2
demonstrates the new Energia window which opens up when the menu item File /Examples / 1.Basics
/ Blink is selected. The syntax shown is legal C++ and utilizes high-level Wiring functions and classes
to provide the following actions within the microcontroller:
(1) Configuration of the physical pin connected to the LaunchPad red LED as a digital output.
(2) Driving the pin connected to the LaunchPad red LED with either a HIGH or LOW voltage in order
to turn the LED on or o respectively.
(3) Execution of a programmable time delay, in units of milliseconds, in order to provide a desired LED
blink pattern.

Figure 1.2 The Energia User-Interface Showing the Blink Example Sketch

Compiling, assembling, linking and uploading this application to the LaunchPad MSP430G2553IN20 is a
simple matter of pressing the right-arrow icon on the Energia toolbar (or via the File / Upload menu
6

<Version: Fall 2015>

EE 4390 Lab 1: Introduction to the MSP-EXP430G2 LaunchPad and Energia

item). The nitty-gritty details of this process appear in the lower dialog window for your amusement (and
soon, edification). Perhaps most importantly, error messages associated with these processes will appear
in the dialog as well. For the first few weeks, these steps will likely appear mysterious, but be assured,
well unlock a lot of the mysteries.

Procedure
Task A (Prelab). This lab has only one minor Prelab step. Each student must obtain, likely through
purchase across the Web, a Texas Instruments MSP-EXP430G2 LaunchPad evaluation kit. This device,
with an MSP430G2553IN20 installed in the DIP socket, should be brought to lab along with the accompanying USB cable. Document in your Lab Notebook the facts regarding where you obtained (or are in
the process of obtaining) your LaunchPad and how much it cost.
The Prelab tasks must be done before you come to lab, and your completed solutions must be included in
your Lab Notebook. Your TA will gather your notebooks to grade your Prelab at the beginning of lab.
Task B (In Lab, EN 5030). The goal of the lab procedure is program the microcontroller so that
the red and green light-emitting diodes (LEDs), located on the bottom edge of the circuit board, flash
repeatedly in the following sequence whenever power is supplied to the LaunchPad:
(a) Only the red LED should turn on for 0.2 seconds.
(b) No LED should be on for 0.3 seconds.
(c) Only the green LED should turn on for 0.5 seconds.
(d) Repeat from step (a).

Setting Up The Windows 7 computers in the Digital Design Lab, as well as the adjacent general computing labs on fifth floor of the Engineering Building, have been configured to have the Energia integrated
development environment installed (with accompanying USB drivers for future serial I/0). To connect your
board, you should only have to log in, connect the small end of the USB cable to the Mini Type B jack
on the LaunchPad, then finally plug the USB cable into the computer. The LaunchPad should power-up
(indicated by a green LED on the EMULATION tab of the board, immediately below the USB jack).
The Energia IDE can be run directly by utilizing the Windows File Explorer to navigate to the folder which
contains the Energia download (for example, C:\ti\energia\energia-0101E0011 or C:\energia-0101E0011
or maybe M:\energia-0101E0014, the latter case being if youve mounted \\warehouse\ece\ee4390 under drive M:) then double-clicking on the Energia application).
Suggested Process for Task B: Once youve started the Energia IDE, ensure that the platform and device shown on the bottom right corner of the Energia window is correct (it should read LaunchPad w/
msp430g2553 (16MHz)). The accompanying COM port information will be USB port dependent. These
settings can be changed through the Tools / Board and Tools / Serial Port menu options. The COM
ports which might have a LaunchPad connected to them are the ones listed on the Serial Port sub-menu.
Select one and try it for uploading as described below. In truth, the COM port assignment wont really
aect us until we attempt to complete programmed serial I/O later in this semester.
<Version: 30 August 2015>

EE 4390 Laboratory Manual

To begin with a simple template code which has much of the capability you need for this exercise, access
the example projects available on the Files / Examples / 1.Basics menu. In particular, the Blink
project should get you started.

Uploading to the Microcontroller: To compile, link and finally upload your program to the LaunchPad
and microcontroller, press the right-arrow icon just below the main menu ribbon of the Energia window.
NOTE: If youd like to see all of the gory details of what the IDE is doing for you in the
background (and you should, we need to master these tasks), go to the File / Preferences
menu and select both check-boxes for Show verbose output during (compilation) (upload). The
microcontroller should reset automatically after upload and begin running your new code.
Your task now is to modify the code from the Blink example in order to complete the specified task,
lighting the red and green LEDs alternately. Good luck!
To fully complete this lab exercise, you must test the timing of your code execution (hint, youll want
to investigate use of the oscilloscope and logic analyzer at your bench to view the timing waveforms for
the digital output lines which are driving the LEDs on the LaunchPad). A smart-phone camera might
come in handy for quickly documenting any measurements available on the scope-face! Be sure to obtain
appropriate documentation for inclusion in your Lab Notebook.
Finally, through some exploration with Windows File Explorer, you should be able to find the source code
of your Sketch (thats Energia talk for the code you wrote). Hint, it should be a file with extension .ino,
and you are likely to want to make a copy of this onto a USB drive or networked drive for later access.
Dont forget to print a copy of it for inclusion in your notebook.

Lab Report in your Lab Notebook


During each regular lab session, your teaching assistant should return your Lab Notebook to you after
grading the Prelab. In lab, maintain a neat and clear record of any procedure steps you take which
might dier from whats described in the lab manual procedure. After lab, tape (strongly encouraged,
and on all four sides) or glue (messy and prone to humidity concerns) a copy of your C/C++/assembly
code in your Notebook. Annotate your notebook pages, noting the correctness or significance
of particular items in the printouts. Dont leave any loose pages in your notebook! You may need to
trim your printouts down to fit nicely onto the pages. Never, ever use staples to attach materials
to your notebook pages. Be sure to include a short (couple of paragraphs) Lessons Learned write-up
for each lab in your Lab Notebook!

<Version: Fall 2015>

S-ar putea să vă placă și