Professional Documents
Culture Documents
Lab2 - PowerModes and ADC MSP430
Lab2 - PowerModes and ADC MSP430
Lab2 - PowerModes and ADC MSP430
This lab consists of two parts. In the first part, you will get familiar with low power modes in
MSP430. In the second part, Analog to Digital Converter of the MSP430 will be used to sample
the accelerometer sensor, perform a simple processing and present the outcome.
1 Lab Objectives
Our hope is that you can finish this lab in one session. We might extend this by one week if
necessary. In the interest of starting the final project as soon as possible, please try your best
to complete the lab in a week.
2 Pre-Lab
Please read chapter 6 section 10 (6.10) of MSP430 textbook and get familiar with low power
modes of MSP430. Consult with the lecture slides. Write a code to put the MCU in low
power mode and use interrupts to return to the main function (study the low power mode
functions in msp430x54x.h). You also need to read Chapter 20 ADC12_A of the
MSP430x5xx/MSP430x6xx Family User's Guide prior to the lab to familiarize yourself with
the general features of the ADC. Review the Datasheet for the Accelerometer on the board.
The codes with all headers and other files are provided. You should understand how to
configure the ADC and the principles behind the sampling. You might be asked to modify
the ADC code. In order to detect the orientation of the board, use the X-axis and the Y-axis
accelerometer inputs. Write a code that uses these two inputs and shows the orientation of
board using the two available LEDs on the experimenter board.
2.1 Requirements
3 Lab Procedure
Repeat all steps you learned in Lab0 to create a new project in CCSv5. You might need to
add other resources to your projects.
Use the code you wrote for the pre-lab to send the MCU to the low power modes 0, 3, 4. Observe
the effect of each mode on the MCU. In the next step, use interrupts to send the MCU to the
active mode. You may use the following functions:
__bis_SR_register(LPM3_bits + GIE);
__bic_SR_register_on_exit(LPM3_bits);
Assume that the board is held perpendicular to the floor (or desk -- parallel to the gravity force
vector). Depending on the exact orientation, you will see the effect of gravity on either or both
axes. In order to detect the orientation of the board, you will need to determine the direction of
these forces. There are five possible scenarios as shown in the following figures. To detect the
board orientation, you must sense the direction in which the forces are exerted. Although the
figures show forces only in one direction, it is clear that when the board is not at the right angle,
gravity will be observed on both axes (i.e., g.Sin() and g.Cos() ). The tripping point to detect
the orientation of board should not be purely 1g. Rather, you should turn on/off LEDs when
particular axis passes a certain point (e.g. 0.6g might be a good value). Once you find the
direction and tripping points, status of LEDs would show the board orientation. In this part of the
lab, you will use LED1 and LED2 to represent five possible scenarios as follows:
o
o
o
o
5 Lab Report
Include the following in your report:
Answers to all questions.
Create a zip file for codes and email it to the TAs along with the report.
6 Documents
There are many useful documents you will need as reference during the labs, these include:
o MSP-EXP430F5438 Experimenter Board User's Guide This document contains all
the information about the Experimenter board you will be using, some of which will be
reproduced here. Designated slau263d and available at the following URL:
http://focus.ti.com/lit/ug/slau263d/slau263d.pdf
o MSP430F5438 Datasheet This documents contains much on the information about
the MSP430 device itself and its specifications. Although you will not have to deal with
the details since you are using a prebuilt board, it is useful to familiarize yourself with it.
http://focus.ti.com/lit/ds/symlink/msp430f5438.pdf
o MSP430x5xx/MSP430x6xx Family User's Guide A must have description of
the MSP430 individual modules. This document describes them in detail including the
registers and the module operation. It will answer many of your questions of how to use
the modules of the MSP430F5438.
http://focus.ti.com/lit/ug/slau208g/slau208g.pdf
o MSP430F5438 Example Code Texas Instruments provides sample code to perform
various functions on the MSP430F5438 and similar MSP430 microcontrollers. This is
usually a good starting point to do things and covers many of the Modules
http://www.ti.com/litv/zip/slac166o