-
LAB 2: Power Modes, and ADC
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
Operation of low power modes o Put the MCU in low power mode o
Waking from low power mode o Returning from low power mode to the
main function
Understand the use and configuration of the ADC Use the
Accelerometer to detect the board orientation
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
Hardware: An MSP430 Flash Emulation Tool (MSP-FET430UIF) and the
Experimenter Board
Software: Code Composer Studio v5
-
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.
3.1 Power Modes of MSP430
Create a new project for the lab and include the file
msp430x54x_UCS_2.c. This code sets different frequencies for MCLK,
SCLK and SMCLK. Run it and use the oscilloscope to measure the
frequency via the test points for the different clocks. The
Experimenter board includes some test points specifically designed
for observing various clocks. The test points also provide a
ground.
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); // Enter Mode3, enable
interrupts __bic_SR_register_on_exit(LPM3_bits); // Exit low power
Mode3
-
3.2 Detecting Board Orientation
The ADC on experimenter board samples two channels that
correspond to the X and Y acceleration axes. Normally with no force
applied, the output voltage is VCC/2 or approximately 1.5V (also
depends on the battery voltage). From that point, the voltage
changes depending on the sensitivity of the accelerometer and the
acceleration force. This information is specified in the datasheet
in mV/g.
In this part of the lab, you will implement an application to
show the X and Y acceleration on display of Experimenter board.
Download the package Lab2_part2_code.zip. Create a project and run
the code. You will see two lines representing the acceleration of
the Experimenter Board in X and Y directions. Note that the gravity
itself creates a force that will show up as 1g when the board is
held sideways.
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:
-
Case1: X and Y accelerations are less than threshold LED1 and
LED2 blinking
Case2: negative accelerations less than threshold in X-axis LED1
= off, LED2 = off
Case3: positive accelerations greater than threshold in X-axis
LED1 = on, LED2 = off
Case4: negative accelerations less than threshold in Y-axis LED1
= off, LED2 = on
Case5: positive accelerations greater than threshold in Y-axis
LED1 = on, LED2 = on
Demonstrate the outcome to the TAs.
-
4 Lab Questions (to be answered in your report)
o What problems did you encounter in this Lab? o What would
determine a proper low power mode for the MSP430? o What is
actually triggering the conversion of the ADC? o Considering the
ADC resolution, how precisely can you measure the X and Y
accelerations? Support your answer with suitable mathematical
equations. o How many ADC block does the MSP430F5438A have? How
many analog sources can
be connected to one MSP430F5438A and accommodated
concurrently?
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
-
o MSP-EXP439F5438(A) Example Software - This software runs on
the Experimenter board and demonstrates the various features such
as LCD, Accelerometer, Microphone, etc.
http://www.ti.com/litv/zip/slac227f