Documente Academic
Documente Profesional
Documente Cultură
Student Guide
Revision 1.2
July 2010
Technical Training
Organization
Important Notice
Important Notice
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to
discontinue any product or service without notice, and advise customers to obtain the latest version of
relevant information to verify, before placing orders, that information being relied on is current and
complete. All products are sold subject to the terms and conditions of sale supplied at the time of order
acknowledgment, including those pertaining to warranty, patent infringement, and limitation of liability.
TI warrants performance of its semiconductor products to the specifications applicable at the time of sale in
accordance with TIs standard warranty. Testing and other quality control techniques are utilized to the
extent TI deems necessary to support this warranty. Specific testing of all parameters of each device is not
necessarily performed, except those mandated by government requirements.
Customers are responsible for their applications using TI components.
In order to minimize risks associated with the customers applications, adequate design and operating
safeguards must be provided by the customer to minimize inherent or procedural hazards.
TI assumes no liability for applications assistance or customer product design. TI does not warrant or
represent that any license, either express or implied, is granted under any patent right, copyright, mask
work right, or other intellectual property right of TI covering or relating to any combination, machine, or
process in which such semiconductor products or services might be or are used. TIs publication of
information regarding any third partys products or services does not constitute TIs approval, warranty or
endorsement thereof.
Revision History
March 2010 Revision 1.0
July 2010 Revision 1.1 Roadmap and portfolio slide update
July 2010 Revision 1.2 Name change
Mailing Address
Texas Instruments
Training Technical Organization
7839 Churchill Way
M/S 3984
Dallas, Texas 75251-1903
ii
Introduction
Introduction
This module will cover the MSP430 architecture, instruction set, and development tools. In the
lab exercise Code Composer Studion will be installed and we will verify that the hardware and
software has been configured properly.
Agenda
Portfolio
2
1-1
Module Topics
Module Topics
Introduction ............................................................................................................................................... 1-1
Module Topics......................................................................................................................................... 1-2
Introduction ............................................................................................................................................ 1-3
TI Processor Portfolio......................................................................................................................... 1-3
5xx Summary...................................................................................................................................... 1-4
MSP430 Generations.......................................................................................................................... 1-5
MSP430 Roadmap.............................................................................................................................. 1-6
Orthogonal CPU ................................................................................................................................. 1-7
Unified Clock System......................................................................................................................... 1-7
5xx Operating Modes ......................................................................................................................... 1-8
Operating Range................................................................................................................................. 1-8
Memory Map ...................................................................................................................................... 1-9
SYS Module ....................................................................................................................................... 1-9
GPIO..................................................................................................................................................1-10
Port Map Module...............................................................................................................................1-10
Universal Serial Communications Interface ......................................................................................1-11
LCD_B and AES128 .........................................................................................................................1-11
USB ...................................................................................................................................................1-12
CC430................................................................................................................................................1-12
Embedded Emulation ........................................................................................................................1-13
Block Diagram...................................................................................................................................1-14
Experimenters Board........................................................................................................................1-14
Code Composer Studio 4.1 ................................................................................................................1-15
Community Support ..........................................................................................................................1-15
Lab 1: Setting up the Software and Hardware.......................................................................................1-17
Objective ...........................................................................................................................................1-17
Hardware / Software Requirements...................................................................................................1-17
Procedure...........................................................................................................................................1-18
1-2
Introduction
Introduction
TI Processor Portfolio
32-bit
real-time
MCUs
MSP430
C2000
Delfino
Piccolo
Up to
25 MHz
40MHz to
300 MHz
Stellaris
ARM Cortex-M3
ARM
Cortex-A8
MPUs
Sitara
ARM Cortex-A8
& ARM 9
C6000
DaVinci
300MHz to
>1GH z
Ultra
Low pow er
DSP
C6000
C5000
video pr oc essors
OMAP
U p to
100 MHz
Flas h
8 KB to 256 KB
USB, ENET
MAC +PHY CAN,
AD C, PWM, SPI
Multi-core
DSP
24.000
MMACS
C ache,
RAM, R OM
300MHz to >1Gh z
+Accelerato r
Ca che
RAM, ROM
Ca che
R AM, ROM
Up to 300 MHz
+Accelerator
Up to 32 0KB RA M
U p to 128 KB ROM
USB, C AN,
PCIe, EMAC
USB, ENET,
PC Ie, SATA , SPI
SRIO, EMAC
DMA, PC Ie
USB, AD C
McB SP, SPI, I 2C
Flas h
1 KB to 256 K B
Analog I/O, A DC
LCD, USB, RF
PWM, ADC ,
CAN, SPI, I 2C
Measurement,
Sensing, General
Purpose
Motor Control,
Digi tal Power,
Li ghti ng, Ren. Enrgy
Connectivity, S ecurity,
Moti on Control, HM I,
I ndustrial Automati on
Medical , Biometrics
$0.25 to $9 .00
$ 1.00 to $8.00
$5 .0 0 to $20.00
$40 to $ 200.00
$3.00 to $1 0.00
Audi o, V oi ce
1-3
Introduction
5xx Summary
Ultra-Low Power
Increased Performance
230 A/MHz
1.9 A standby mode
Wake up from standby in < 5 s
Up to 25 MHz
8 MHz across entire operating range
(1.8 - 3.6 V)
1.8V ISP flash erase & write
Fail-safe, flexible clocking system
Innovative Features
1-4
Introduction
MSP430 Generations
MSP430 Generations
1xx
2xx
4xx
5xx
FLL, F LL +
Programmable
Core Voltage
with integrated PMM
16-bit CPU
16-bit CPUXV2
GPIO
GPIO
GPIO w/pull-up
and pull-down,
drive strength
N/A
N/A
N/A
CRC 16
Software RT C
Software R TC
USART
USCI, USI
USAR T, USCI
USCI, USB, RF
DMA up to 3-ch
DMA up to 3-ch
DMA up to 3-ch
DMA up to 8-ch
MPY16
MPY16
MPY16, MPY32
MPY32
ADC10,12
ADC10,12
ADC12
ADC12_A
4- wire JT AG
4-wire JTAG
4-wire JT AG and
Spy-Bi-Wire
MSP430 Generations
5
1-5
Introduction
MSP430 Generations
Category
2xx
4xx
5xx
16MH z
8MHz
25MH z
Active Current
(@ 3.0V, typical)
515u A @ 1MH z
4.2mA @ 8MH z
6 00uA @ 1MHz
4 .8m A @ 8MHz
290u A @ 1 MHz
1.84mA @ 8 MHz 23 0 u A/MHz
9.1mA @ 16 MHz
N /A
8.90mA @ 2 5MHz
1us
6us
5us
0.9 1.1uA
1.1 2.5uA
LPM4 Current
0.1uA
0.1uA
2.2V
2.7V
1.8V
P1/P2
P1/P2
P1/P2
N/A
N/A
N/A
500 uA
500 uA
100 uA*
800 uA
800 uA
150 uA*
DCO
LFXT1
XT 2 (if available)
VLO
F LL
LF XT 1
XT2 (if available)
N/A
LF XT 1
F LL
LFXT 1 / XT 1
XT2 (if available)
VLO
R EF O
UCS
LFXT1, REFO,
& XT2 (if pr esent)
Roadmap
MSP430 Roadmap
MSP430 Roadmap
Device
Produ ct ion
Developm en t
F51x2
Lighti ng
16 M Hz
120 kB F lash
8 kB RAM
500 nA Stand by
1.8 3. 6V
F = Flash
C = ROM
FR = FRAM
8M Hz
60 kB Fl ash
10 kB RAM
1. 8 3.6 V
RF
F6/563x
BGM, Catal og
F 53xx
F543x
F541x
The Ne w Ge ne ration
5xx-6xx
Gen Purpose
L 092
0.9V Nati ve
F 21x2
F21x1
1xx-Catalog
USB
USB
F22xx
75 + de vices
F550x
F23x0
F23x0
F20xx
F552x
FRAM
F261x
F241x
F23x-F24x
2xx-Catalog
CC430
FR57xx
100+ dev ic es
F15x-F16x
F/CG461x
F13x- F14x
Fx43x
F12xx
F44x
F/C11xx
Fx42x
F 47x4
Fx42x0
F/C41x F E42x2
F41x2
F 471xx
Fx47x
25M Hz
256 kB Fl ash
16 kB RAM
1. 8 3.6V
FRAM , US B, RF
6xx: L CD Control ler
230 uA/M Hz
10 0+ devices
4xx: L CD
Up to 16 M Hz
120 kB Fl ash
8 kB RAM
L CD Control ler, 160
seg men ts
1. 8 3.6V
CPU
1-6
Introduction
Orthogonal CPU
friendly
Memory address range increased to
1MB
CPU
Instruction compatible
with previous
CPU
Cycle
count optimization
all instructions
UCS
8
Low Freq
LFXT1
VLO
32768 Hz crystal
10 kHz
REFO
32 kHz
High Freq
XT1
XT2
4 32 MHz crystal
4 32 MHz crystal
DCO
clock
LFXT1 / XT1
REFO
XT2
1-7
Introduction
CPU active
LPM0 70 uA
CPU disabled
Fast Peripher als Enabled
LPM3 1.9 uA
CPU disabled
Fast Peripher als Disabled
LPM4 1.2 uA
Wake on interrupt
Operating Range
10
Operating Range
5xx Voltage vs. Frequency Operating Range
Programmable VCORE
maximizes power
efficiency
Lowering VCC or VCORE
reduces system current
Mem Map
11
1-8
Introduction
Memory Map
Always a contiguous
block
SYS
12
SYS Module
Reset events
NMIs split into SYSNMI & UNMI
SYSNMIs have higher priority
Separate interrupt vectors
SVSL (POR)
SVSH (POR)
SVML_OVP (POR)
SVMH_OVP (POR)
DoPOR (POR)
WDT time out (PUC)
GPIO
13
1-9
Introduction
GPIO
14
USCI
15
1 - 10
Introduction
URXD
SOM I
Baud -Rate
Gener ator
ST E
SIMO
UTXD
UxTXBUF
UCLK
16
17
1 - 11
Introduction
USB
5xx + USB
V USB
+5V VBUS
PUR
DD+
USB
Module
TPD2E00 1DRL
CPU
Power Supply
& Superv is ion
RAM
DMA
Timers RTC
Clock s
ESD
DVCC
12-bit
ADC
32x32
MPY
Flash
CRC
16
Comparator
Serial
Comms
4MHz
ESD Protection
Diode Arr ay
CC430
18
CC430
Low-power
RF SoC
Low Power
RF IC
MSP430
MCU
Radio Frequency
Application &
Protocol
processor
Low Power
< 1 GHz RF
Transceiver
High sensitivity
Low current consumption
Excellent blocking performance
Flexible data rate & modulation format
Backwards compatible
MSP430
5xx MCU
Ultra-low power
High analog performance
High level of integration
Ease of development
Sensor interface
Emulation
19
1 - 12
Introduction
Embedded Emulation
Emulation
20
Block Diagram
21
1 - 13
Introduction
Block Diagram
MSP-EXP430F5438
22
Experimenters Board
MSP-EXP430F5438
USB communication
Microphone
Filtered PWM audio output
2-axis accelerometer
Dot-matrix LCD (138x110)
Integrated backlight
1 x 5-direction switch
2 x push-button switches
RF Interface
CCxxxx EVMs
EZRF I/F (6 & 18- pin)
Please ensure 2 x AA
batteries are in place on
the back of the board
23
1 - 14
Introduction
Enhancements:
Speed
Code
size improvements
Auto-updating
License
manager
Support for all TI MCUs
Community Support
24
Community Support
Blogs, Forums
Extensive community
support and idea exchange
Global customer support
http://e2e.ti.com
Processor Wiki
Growing
collection of
technical wiki articles
Tips & tricks, common
pitfalls, and design
ideas
http://wiki.msp430.com
Lab_1
25
1 - 15
Introduction
1 - 16
Agenda
26
1 - 17
Procedure
If youve already completed the installation steps that were emailed to you before the
workshop, skip to step 9.
3. Open the Setup CCS folder on your desktop and double-click on the file named
setup_CCS_n.n.n.n.exe.
4. Follow the instructions in the Code Composer Studio installation program. Select
the Platinum Edition for installation when the Product Configuration dialog
window appears. Click Next.
1 - 18
5. In the Choose ISA dialog, make sure that only the MSP430 checkbox is selected.
Click Next.
In the Select Components dialog, uncheck the Target Content and Emulators
checkboxes then check the MSP430 USB FET checkbox and click Next. Click
Next in the Start Copying Files dialog. The installation should take less than 10
minutes to complete.
1 - 19
Driver Installation
6. Download the workshop installation files from this link on the MSP430 One Day Workshop Wiki site. Unzip the file to your desktop (the folder name is MSP430).
7. In the unzipped MSP430 folder on your desktop, open the USB drivers folder. Doubleclick on setup.exe. Follow the wizard steps until it completes. Then, using Windows Explorer, navigate to C:\Program Files\Texas Instruments Inc\TUSB3410 Single Driver
Installer\DISK1 and double-click on setup. Follow the wizard steps until the driver installation completes.
Hardware Setup
9. Connect the USB cable to the MSP-FET430UIF port marked USB and that the other end
of the cable to your computers USB port. Your computer should recognize the new USB
device.
10. Next, connect the ribbon cable to the MSP-FET430UIF port marked Target and the
other end to the JTAG emulation debug port on the MSP-EXP430F5438 Experimenters
Board.
1 - 20
11. The MSP-EXP430F5438 Experimenters Board has several jumpers that control power to
the board:
JP2 SYS PWR provides power to the entire MSP-EXP430F5438 board (ON)
Used to measure current consumption of the entire board
1 - 21
After a few moments, the Workspace Launcher window will appear. In the Workspace
window, enter C:\ 5xx_ODW\workspace and click the OK button on the lower right.
This will create a workspace folder in that location. All of the workshops lab project
folders will be added to this location as we work on them.
1 - 22
13. If you are prompted to review and install updates, click No. When the license dialog
appears, select Evaluate Code Composer for 30 days and click OK.
When the Welcome screen appears, close it by clicking on the CCS emblem in the upper
right corner.
1 - 23
1 - 24
If the Cheat Sheets pane is open on the right, close it by clicking the X on the tab.
The left-hand pane is the Project pane. All of the components; libraries, source files,
settings, etc. that comprise a project are displayed here. The middle pane is the
Workspace pane. When you are editing, the Eclipse editor will be seen here, along with
tabs to the files being edited. The Outline pane, on the right, displays C/C++ file
elements, like structures, etc.
Click on the + next to Lab_1 to expand the project.
1 - 25
"msp430x54x.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1OUT = 0x00;
P1DIR |= BIT0;
WDTCTL = WDT_ADLY_1000;
SFRIE1 |= WDTIE;
__enable_interrupt();
}
// Watchdog Timer interrupt service routine
#pragma vector = WDT_VECTOR
__interrupt void WDT_ISR(void)
{
SFRIFG1 &= ~WDTIFG;
P1OUT ^= 0x01;
// Toggle P1.0 using exclusive-OR
}
1 - 26
1 - 27
Youre done.
1 - 28
2-1
Module Topics
Module Topics
Active and Low Power Operation............................................................................................................ 2-1
Module Topics......................................................................................................................................... 2-2
Active and Low Power Operation ........................................................................................................... 2-3
Ultra-Low Power Best Practices......................................................................................................... 2-3
Unified Clocking System (UCS) ........................................................................................................ 2-5
Power Management Module (PMM).................................................................................................. 2-7
Interrupts and the Stack ...................................................................................................................... 2-9
Intrinsics ............................................................................................................................................. 2-9
Fail-Safe Behavior.............................................................................................................................2-10
Available Oscillators .........................................................................................................................2-10
Overview of Lab2 Exercise ...............................................................................................................2-11
Lab 2: Active and Low Power Mode Operation ....................................................................................2-12
Objective ...........................................................................................................................................2-12
Procedure...........................................................................................................................................2-14
2-2
2-3
Vcc
CPU clock speed (MCLK)
Temperature
Driven as outputs
Be driven at Vcc/ground by an external device
Have a pull-up/down resistor
2-4
FLLREFCLK = XT1CLK
ACLK = XT1CLK
MCLK = DCOCLKDIV
SMCLK = DCOCLKDIV
DCOCKLDIV = DCOCLK / 2
DCO_freq ~= 2 MHz, so
MCLK_freq ~= 1 MHz
SMCLK_freq ~= 1MHz
FLLREFCLK sources:
N = FLLN
D = FLLD
2-5
PMM
33
2-6
Unlock:
Lock:
PMMCTL_H = 0xA5
PMMCTL_H = 0x00
(2 us response time)
V core
34
2.
3.
4.
35
2-7
5 us wake up fr om LPM2,3,4
+0 uA active & LPM 2,3 ,4 current
consumption
c onsumption
0 nA LPM2 ,3,4 curr ent
c onsumption
Entering LPMs
36
2-8
Int rinsics
38
Intrinsics
Using Intrinsic Functions to
Program the Status Register (SR)
Intrinsic Functions:
__bi c_ SR_reg iste r(LPM3 _bits);
__bi c_ SR_reg iste r_on_ exit(LPM3 _bits);
__bi s_ SR_reg iste r(LPM3 _bits + GIE);
__bi s_ SR_reg iste r_on_ exit(unsign ed short a);
__ge t_ SR_re giste r(void) ;
__ge t_ SR_re giste r_on _exit(void) ;
__en able _interr upts( ) ;
__di sa ble_i nterrup ts( );
39
2-9
Fail-Safe Behavior
Fail-Safe Behavior & Clock Requests
Available Oscillators
40
Available Oscillators
Frequency
Precision
Current Draw
DCO
100kHz
60MHz
Low
60uA
HFXT1/
XT2
4 - 32MHz
High
260uA @
12MHz
MODOSC
5MHz
n/a
n/a
Crystal
Required
High-Frequency
Low-Frequency
RTC
LFXT1
VLO
REFO
32kHz
~10kHz
32kHz
High
Low
Medium/High
300nA
60nA
3uA
Lab_2
41
2 - 10
Agenda
42
2 - 11
Active running at 25 MHz change the COREV levels for greater than 8 MHz
operation
LPM3 VLO evaluate ultra-low power tradeoffs for oscillators at VLO ACLK
The LPM3 applications blink the LED on and off every 3 seconds. After you have verified that
the application download and function, you can comment out the line P1OUT ^= ~BIT0; . This
will allow you to measure the current without the spikes due to the LED.
2 - 12
In the Active Running scenarios (first two in the box above) a function is called to provide a
current consumption test. This test includes a mix of various MSP430 instructions (type I, II,
JMP, emulations, etc.) and uses various MSP430 addressing modes. The function is called from
C with the following code:
// Call active mode current consumption test
ACTIVE_MODE_TEST();
ACTIVE_MODE_TEST
IDD_AM_L1
.global
.text
MOV
MOV
MOV
ADD
SWPB
MOV
; run 8
XOR
DEC
JNZ
JMP
.end
ACTIVE_MODE_TEST
#0x2000, R4
#0x4, 0(R4)
&0x2000, &0x2002
@R4, 2(R4)
@R4+
@R4, R5
times
@R4+, &0x2020
R5
IDD_AM_L1
ACTIVE_MODE_TEST
2 - 13
Procedure
Import CCS Project
1. Import the CCS project for this lab exercise by clicking:
Project Import Existing CCS/CCE Eclipse Project
Then in the Import dialog window click Browse and navigate to: C:\5xx_ODW\ Lab_2.
Select Lab_2 in the Projects box, check the Copy projects into workspace checkbox
and click Finish.
In the Project pane of CCS, click the plus sign (+) to the left of Lab_2 and notice the
files are listed for the various low power measurement scenarios. Note that the
ACTIVE_8_MHZ.c file is included in the build.
2 - 14
Init_FLL_Settle( ) selects the RSEL, DCO taps, delay for FLL to settle, and
MCLK, SMCLK, ACLK sources
Check the MSP430 application notes for hal_UCS and hal_PMM library
descriptions
8. Turn on your multimeter and set it to a range that can measure <10mA. (Be sure that the
leads are connected to the proper jacks to read current).
9. Remove and save the JP1 MSP430 PWR jumper and connect the multimeter leads to
the header with the red lead closest to the edge of the board.
2 - 15
10. Measure the current consumption:__________ (It should be between 1.9 mA 2.1 mA).
11. Some further information:
Since the CPU performs a 32-bit fetch, code alignment can impact current consumption
significantly
2 - 16
SVSx & SVMx management turns off SVSL and SVSM, leaves SVSH in full
performance mode, and delivers fast wake-up (5 s) time with SVS protection on
DVcc
button.
16. Disconnect the 14-pin JTAG cable from the Experimenters board and move the SW1
FET/USB/BATT power supply switch to BATT.
17. Turn on your multimeter and set it to a range that can measure <10mA. (Be sure that the
leads are connected to the proper jacks to read current).
18. Remove and save the JP1 MSP430 PWR jumper and connect the multimeter leads to
the header with the red lead closest to the edge of the board.
19. Measure the current consumption:__________ (It should be between 7.1 mA 8.3 mA).
2 - 17
button.
24. Disconnect the 14-pin JTAG cable from the Experimenters board and move the SW1
FET/USB/BATT power supply switch to BATT.
25. Remove and save the JP1 MSP430 PWR jumper and connect the multimeter leads to
the header with the red lead closest to the edge of the board.
26. Turn on your multimeter and set it to the lowest DC milliamp measurement range. (Be
sure that the leads are connected to the proper jacks to read current).
27. LED1 on the Experimenters board will blink ON and OFF if the program is running
correctly.
28. Measure the current consumption while LED1 is OFF:__________ (It should be
between 4.3 A 4.9 A).
2 - 18
LFXT_Start (XT1DRIVE_0);
<hal_UCS.c>
button.
33. Disconnect the 14-pin JTAG cable from the Experimenters board and move the SW1
FET/USB/BATT power supply switch to BATT.
34. Remove and save the JP1 MSP430 PWR jumper and connect the multimeter leads to
the header with the red lead closest to the edge of the board.
35. Turn on your multimeter and set it to the lowest DC milliamp measurement range. (Be
sure that the leads are connected to the proper jacks to read current).
36. LED1 on the Experimenters board will blink ON and OFF if the program is running
correctly.
37. Measure the current consumption while LED1 is OFF:__________ (It should be
between 1.9 A 2.4 A).
2 - 19
button.
42. Disconnect the 14-pin JTAG cable from the Experimenters board and move the SW1
FET/USB/BATT power supply switch to BATT.
43. Remove and save the JP1 MSP430 PWR jumper and connect the multimeter leads to
the header with the red lead closest to the edge of the board.
44. Turn on your multimeter and set it to the lowest DC milliamp measurement range. (Be
sure that the leads are connected to the proper jacks to read current).
45. LED1 on the Experimenters board will blink ON and OFF if the program is running
correctly.
46. Measure the current consumption while LED1 is OFF:__________ (It should be
between 1.2 A 1.6 A).
Youre done.
2 - 20
Analog Peripherals
Introduction
This module will discover the mixed-signal capability of the MSP430 architecture and learn
about its effect on low power operation. In the lab exercise we will measure an analog signal
using the integrated temperature sensor, perform an analog-to-digital conversion, and send the
results over a USB link to a CCS4 terminal window.
3-1
Module Topics
Module Topics
Analog Peripherals.................................................................................................................................... 3-1
Module Topics......................................................................................................................................... 3-2
Analog Peripherals ................................................................................................................................. 3-3
Comp_B Analog Comparator ............................................................................................................. 3-3
ADC12_A........................................................................................................................................... 3-4
Conversion Memory and Control ....................................................................................................... 3-5
Lab 3 Overview .................................................................................................................................. 3-6
Lab 3: Brute-Force Temperature Sampling............................................................................................ 3-8
Objective ............................................................................................................................................ 3-8
Procedure............................................................................................................................................ 3-9
3-2
Analog Peripherals
Analog Peripherals
Comp_B Analog Comparator
ADC12_A
44
3-3
Analog Peripherals
ADC12_A
ADC12_A Features
Timer_A/B, software
triggers
Up to 12 external input
Conversion Modes:
Single
Sequence
Repeat-single
Repeat-sequence
Internal/external
reference
16 conversion result
storage
45
ADC12_A Enhancements
3-4
Analog Peripherals
48
3-5
Analog Peripherals
Lab 3 Overview
Lab 3: Brute-force Temperature Sampling
Lab 3 code
49
//
//
//
//
// Delay 2 seconds
}
}
Alphabet Soup
50
3-6
Analog Peripherals
(msp430x54xA.h file)
(User Guide)
Lab 3 Power
51
540 uA
Curre nt
Lab 3 Power
Active
A DC
= 150uA
A ctive
ADC
= 150uA
3 90uA
1. 5V Internal Ref erence = 100uA
2 90uA
75us
80us
Active MCLK
@1MHz=290uA
Time
2 seconds until next Sample
CPU
__delay_cycles(2200000);
ADC12
52
3-7
implementation had no interrupts, all CPU delays and flag polling. Current draw was
about 300 uA.
Lab 4 will use timer interrupts. We will handle the two second delay with a hardware
timer interrupt. This will prove to be the most significant decrease in power
consumption.
Lab 5 will be a fully optimized ADC12 routine. We will use the ADC12 interrupts to
signify end-of-conversion. The timer will automatically handle the reference settling
time as well as trigger the ADC12 sampling. This will maximize the time that the
CPU spends in LPM3.
FET
Agenda
53
3-8
Procedure
Import CCS Project
1. Import the CCS project for the next three lab exercises by clicking:
Project Import Existing CCS/CCE Eclipse Project
In the Import dialog window click Browse and navigate to the C:\5xx_ODW folder and
select OK. Next, in the Projects window check Lab_3, Lab_4, and Lab_5 (be sure all
three labs are selected). Then check the Copy projects into workspace checkbox and
click Finish.
2. Set Lab_3 as the [Active Lab3] project by right-clicking on Lab_3 in the Project pane
and selecting Set as Active Project. Click the plus sign + to the left of Lab_3 and
notice the files are listed for the project.
3-9
To understand how the above code example works, first the bit field descriptions are
found in the Users Guide:
3 - 10
6. Turn on your multimeter and set it to a range that can measure about 300uA. Click the
button to assemble/compile and download the executable into the device
Debug
flash memory.
7. Click the Run
Baud Rate:
9600
Data Bits:
Stop Bits:
Parity:
none
Flow Control:
none
Timeout (sec):
11. Now you should see scrolling temperature (in C and F) and the voltage in the Terminal
pane. Verify the temperature reading changes in the terminal window by placing your
finger or breathing on the MSP430 device on the board.
3 - 11
Current Measurement
12. Disconnect the 14-pin JTAG cable from the Experimenters board.
13. Click the Disconnect
button in the Terminal pane and disconnect the USB-tominiUSB cable from your PCs USB port.
14. Observe the current consumption. Because of the timer delay and the meters inability to
read quickly changing currents, your readings will jump around
// Delay 2 seconds
15. Turn off your multimeter and reconnect the 14-pin JTAG cable and the USB-tominiUSB cable.
16. Click the Terminate All
button.
Youre done.
3 - 12
Hardware Timers
Introduction
This module will discuss the features of the MSP430 hardware timers. Many microprocessors
incorporate timer to generate simple time intervals. The timers on the MSP430 include additional
capabilities for generating PWM waveforms, controlling the ADC hardware, and even implement
UART communication functions. In the lab exercise we will build on the previous exercise and
use the hardware timers to conserve power.
4-1
Module Topics
Module Topics
Hardware Timers ...................................................................................................................................... 4-1
Module Topics......................................................................................................................................... 4-2
Hardware Timers .................................................................................................................................... 4-3
Timer Architecture ............................................................................................................................. 4-3
Counting Modes ................................................................................................................................. 4-4
Interrupts ............................................................................................................................................ 4-4
Timer_B vs Timer_A.......................................................................................................................... 4-5
Lab 4 Details....................................................................................................................................... 4-6
Lab 4: Using Hardware Timers to Conserve Power............................................................................... 4-7
Objective ............................................................................................................................................ 4-7
Procedure............................................................................................................................................ 4-8
4-2
HaTrdware Timers
Hardware Timers
Timer Architecture
Timer Architecture
Asynchronous 16-bit
timer/counter
Continuous, up-down,
up count modes
Multiple
capture/compare
registers
PWM outputs
Timer Modes
55
4-3
HaTrdware Timers
Counting Modes
Interrupts
56
Interrupts
Timer_B Interrupts
The Timer_B Capture/Comparison Register 0 Interrupt Flag
(TBCCR0) generates a single interrupt vector:
TBCCR0 CCIFG
No handler is required
TIMERB0_VECTOR
TBCCR1 CCIFG
TBCCR2 CCIFG
TBIV
TIMER_B1_VECTOR
TBIFG
Your code must contain a handler to determine which Timer_B
interrupt triggered
The same applies to Timer_A
B vs A
57
4-4
HaTrdware Timers
Timer_B vs Timer_A
Timer_B vs Timer_A
Lab 4 Flowchart
58
4-5
HaTrdware Timers
Lab 4 Details
Lab 4 Power
59
54 0uA
Curr ent
Lab 4 Power
Active
ADC
= 150uA
Acti ve
ADC
= 150uA
390u A
1. 5V Internal Ref erence = 100uA
290u A
75us
80us
Active MCLK
@1MHz=290uA
2.1uA
Time
2 seconds until next Sampl e
60
4-6
FET
Agenda
61
4-7
Procedure
Set Active Project and Check COM Port Connection
1. Set Lab_4 as the [Active Lab 4] project by right-clicking on Lab_4 in the Project
pane and selecting Set as Active Project. Click the minus sign (-) next to Lab_3 to
collapse the Lab_3 project. Click the plus sign (+) next to Lab_4 and notice the files are
listed for the project.
2. Make sure that the small size connector of the USB-to-miniUSB cable is connected to the
MSP-EXP430 board and the other end to the USB port on your computer. Also make
sure your emulator cables are properly connected.
Timer_ISR( )
4. Turn on your multimeter and set it to a range that can measure about 50uA. Click the
Debug
button to assemble/compile and download the executable into the device
flash memory.
5. Click the Run
4-8
button.
7. You should see scrolling temperature (in C and F) and the voltage in the Terminal
pane. Verify the temperature reading changes in the terminal window by placing your
finger or breathing on the MSP430 device on the board.
Current Measurement
8. Disconnect the 14-pin JTAG cable from the Experimenters board.
9. Click the Disconnect
button in the Terminal pane and disconnect the USB-tominiUSB cable from your PCs USB port.
10. Observe the current consumption. Because of the timer delay and the meters inability to
read quickly changing currents, your readings will jump around
4-9
11. Turn off your multimeter and reconnect the 14-pin JTAG cable and the USB-tominiUSB cable.
12. Click the Terminate All
button.
Youre done.
4 - 10
5-1
Module Topics
Module Topics
Optimized ULP ADC12 Routine.............................................................................................................. 5-1
Module Topics......................................................................................................................................... 5-2
Optimized ULP ADC12 Routine ............................................................................................................. 5-3
Timer Output and Triggering.............................................................................................................. 5-3
Timer_B Interrupts ............................................................................................................................. 5-4
Handler ............................................................................................................................................... 5-4
Interrupt Control................................................................................................................................. 5-5
How to Write the ADC12IFG1 Handler............................................................................................. 5-5
Lab 5 Code ......................................................................................................................................... 5-6
Lab 5 Power........................................................................................................................................ 5-6
Lab 5: Fully Automated ADC12 Routine ................................................................................................ 5-7
Objective ............................................................................................................................................ 5-7
Procedure............................................................................................................................................ 5-8
5-2
Power Optimization:
Currently: Tim er delays for 2 seconds, software ADC12 trigger
Optimization: Timer delays for 2 seco nds, then:
Time between TBIFG and TBCCR1 must be > 75 us for 2.0V REF to stabilize
Timer Interrupts
64
5-3
Timer_B Interrupts
Timer_B Interrupts
The Timer_B Capture/Comparison Register 0 Interrupt Flag
(TBCCR0) generates a single interrupt vector:
TBCCR0 CCIFG
TIMERB0_VECTOR
TBCCR1 CCIFG
TBCCR2 CCIFG
TBIV
TIMER_B1_VECTOR
TBIFG
Handler
65
Handler
Source
TAIV Contents
No interrupt pending
0
02h
TBCCR1 CCIFG
04h
TBCCR2 CCIFG
06h
Reserved
08h
Reserved
0Ah
TBIFG
0Ch
Reserved
0Eh
Reserved
0xF814
0xF814
0xF818
0xF818
0xF81A
0xF81A
0xF81C
0xF81C
0xF81E
0xF81E
0xF820
0xF820
0xF822
0xF822
0xF824
0xF824
0xF828
0xF828
0xF82A
0xF82A
0xF82E
0xF82E
0xF830
0xF830
0xF834
0xF834
add.w
add.w
reti
reti
jmp
jmp
jmp
jmp
reti
reti
reti
reti
jmp
jmp
xor.b
xor.b
reti
reti
xor.b
xor.b
reti
reti
xor.b
xor.b
reti
reti
&TB0IV,PC
&TB0IV,PC
0xF824
0xF824
0xF82A
0xF82A
0xF830
0xF830
#0x4,&P1OUT
#0x4,&P1OUT
#0x2,&P1OUT
#0x2,&P1OUT
#0x1,&P1OUT
#0x1,&P1OUT
Interrupt Control
66
5-4
Interrupt Control
Power
optimization:
Currently:
Optimization:
ADC12
Lab 5 Code
68
5-5
Lab 5 Code
Lab 5 Code
Main
ADC12MEM1 ISR
Lab 5 Power
69
Lab 5 Power
Curr ent
Lab 5 Power
252 uA
Acti ve
ADC
= 150uA
A ctive
ADC
= 150uA
102 uA
1. 5V Internal Ref erence = 100uA
2 .1 uA
Time
2 seconds until next Sampl e
Entry/exit to ISR
Disables the reference
Stores the ADC12MEM0 & ADC12MEM1 values
Wakes active on exit from LPMx
Lab 5
70
5-6
FET
Agenda
71
5-7
Procedure
Set Active Project and Check COM Port Connection
1. Set Lab_5 as the [Active Lab 5] project by right-clicking on Lab_5 in the Project
pane and selecting Set as Active Project. Click the minus sign (-) next to Lab_4 to
collapse the Lab_3 project. Click the plus sign (+) next to Lab_5 and notice the files are
listed for the project.
2. Make sure that the small size connector of the USB-to-miniUSB cable is connected to the
MSP-EXP430 board and the other end to the USB port on your computer. Also make
sure your emulator cables are properly connected.
Put TimerB into continuous mode, set/reset output mode on CCR1, enable TBIFG
interrupts, and trigger CCR1 rising edge > 75 s (t_ref_settle) after TBIFG ISR
turns on the reference
void halTimerInit(void)
{
TB0CCR0
= 65535;
TB0CCR1
= 3;
// 3 x 1/32768kHZ = 91us
TB0CCTL1 = OUTMOD_3;
// CCR1 output mode to TB0CCR1
// ACLK, continuous mode, clear TBR
TB0CTL
= TBSSEL_1 + MC_2 + TBCLR + TBIE;
}
5-8
}
}
4. Turn on your multimeter and set it to a range that can measure about 50uA. Click the
Debug
button to assemble/compile and download the executable into the device
flash memory.
5. Click the Run
button.
7. You should see scrolling temperature (in C and F) and the voltage in the Terminal
pane. Verify the temperature reading changes in the terminal window by placing your
finger or breathing on the MSP430 device on the board.
5-9
Current Measurement
8. Disconnect the 14-pin JTAG cable from the Experimenters board.
button in the Terminal pane and disconnect the USB-to9. Click the Disconnect
miniUSB cable from your PCs USB port.
10. Observe the current consumption. Because of the timer delay and the meters inability to
read quickly changing currents, your readings will jump around
In this application the CPU is not active during reference settling and sampling. The CPU
wakes for a very short period of time to enter/exit ISR and store results.
11. Turn off and disconnect your multimeter from the MSP-EXP430 board. Reconnect the
JP1 MSP430 PWR jumper. Disconnect the USB-to-miniUSB cable from the board.
12. Click the Terminate All
button.
Shut Down
13. Disconnect the FET USB cable from your PC and shut down Code Composer Studio.
Youre done.
5 - 10
6-1
Module Topics
Module Topics
Tools, Resources and Conclusion............................................................................................................. 6-1
Module Topics......................................................................................................................................... 6-2
Tools ....................................................................................................................................................... 6-3
Programming Tools ................................................................................................................................ 6-5
Boards..................................................................................................................................................... 6-6
Software Tools and Resources ................................................................................................................ 6-7
Conclusion .............................................................................................................................................. 6-8
6-2
Tools
Tools
IAR for MSP430
CCS
73
Enhancements:
Speed
Code
size improvements
Auto-updating
License
manager
Support
eZ430 Tools
74
6-3
Tools
FETs
75
6-4
Programming Tools
Programming Tools
Programming Tools
Parallel FET
USB FET
76
Target Boards
77
6-5
Boards
Boards
Target Boards for Device Programming
MSP-EXP430FG4618
78
Connector for
CC1100/CC1101/
CC2500/CC2420 EMs
SW examples and
function library available
at www.ti.com/ccmsplib
Software Tools
79
6-6
TI-MAC
SimpliciTI (on MSP430 MediaWiki)
DASH7
Wireless M-Bus
6LoPAN
Operating Systems
uC-OSII
IAR PowerPac
Salvo
FreeRTOS
www.ti.com
80
www.ti.com/msp430
Users Guides
Datasheets
Code Libraries
Product Brochure
Silicon Errata
Summary
81
6-7
Conclusion
Conclusion
5xx Generation Summary
Ultra-Low Power
Increased Performance
230 A/MHz
1.9 A standby mode
Wake up from standby in < 5 s
Up to 25 MHz
8 MHz across entire operating range
(1.8 - 3.6 V)
1.8V ISP flash erase & write
Fail-safe, flexible clocking system
Innovative Features
82
Dont Forget!
6-8