T exas 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 acknowledgement, 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 TI’s 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.
CERTAIN APPLICATIONS USING SEMICONDUCTOR PRODUCTS MAY INVOLVE POTENTIAL RISKS OF
DEATH, PERSONAL INJURY, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE (“CRITICAL
APPLICATIONS”). TI SEMICONDUCTOR PRODUCTS ARE NOT DESIGNED, AUTHORIZED, OR
WARRANTED TO BE SUITABLE FOR USE IN LIFE-SUPPORT DEVICES OR SYSTEMS OR OTHER
CRITICAL APPLICA TIONS. INCLUSION OF TI PRODUCTS IN SUCH APPLICATIONS IS UNDERST OOD TO
BE FULLY AT THE CUSTOMER’S RISK.
In order to minimize risks associated with the customer’s 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. TI’s publication of information regarding any third
party’s products or services does not constitute TI’s approval, warranty or endorsement thereof.
This chapter provides installation and programming instructions for the starter Kit MSP-STK430x320, and
the evaluation Kits MSP-EVK430x320 and MSP-EVK430x320.
NOTE:
This manual covers both the MSP-STK430x320 and MSP-EVK430x320 kits. The
actual icons and/or windows on the computer screen may differ from those shown
in the book due to software version upgrades.
In this documentation, the term STK/EVK is used interchangeably to represent both kits. The programs used
in this manual are provided in the installation directory ..\stk\examples, or in ..\evk\examples. These
programs demonstrate the user-friendly environment of the MSP430 starter and evaluation kits.
The main difference between the MSP-EVK430x320 and the MSP-EVK430x330, besides the peripheral
blocks, is the memory map. The memory map is described in chapter 2 under Memory Organization.
1.1Installing the Software
Exit all MS-Windows programs prior to loading this software.
The setup program installs all necessary files for running programs on the STK/EVK. The setup program
adds the appropriate program group and icons to the Windows program manager.
To install the software:
1. Insert MSP430-STK/EVK disk 1 in the floppy drive and run setup.exe.
2.In the Select Components window, choose the applications to load. The Starter Kit and
Simulation Environment button are the default. Make a choice and select Next.
3.Choose the desired COM port for the hardware connection. The default is set to COM port 2.
Select the port to be used, then select Next.
4.Read the licensing agreement and answer the question at the bottom of the screen. If YES is
selected to the licensing agreement, a prompt to close all other applications running in Windows
will appear.
5.The setup.exe program automatically creates and loads the MSP430-STK/EVK software to the
recommended directory (C:\ADT430), unless otherwise indicated. Choose the directory and
select Next.
6.Insert Disk 2 when prompted. Select OK when disk 2 is in the floppy drive.
7.Setup.exe places MSP430 icons in the ADT430 program folder, unless otherwise indicated.
Select Next.
8.Setup is complete. Please take a moment to fill out and return the registration card to ensure
receiving further software updates.
The ADT430 program folder should contain the following icons: Simulation Environment, Read me SIM,
Help SIM, ASM430 Assembler, Sensor Demo, and UnInstall the STK430 and EVK430 Terminals.
MS-Windows is a trademark of Microsoft Corp.
1–1
Page 8
Figure 1–1. MSP-STK430 Program Group
Figure 1–2. MSP/EVK430 Program Group
NOTE: EVK/STK430 Terminal icon
Before clicking the EVK/STK430 Terminal icon, ensure the standard Windows Applications
Terminal and Notepad are installed in the Windows directory. The Windows terminal emulator
is configured to use serial port COM2 by default.
1.2Hardware Installation
The STK/EVK kit hardware includes the STK/EVK-PCB and one 9-pin cable for connection to the PCs serial
communication port. The EVK also contains the PRG430 along with the necessary cables.
1.2.1The STK/EVK-PCB Operating Conditions
Temperature range10°C – 45°C
Humidity40% – 70%
Current consumption
(Approximate V alues)
Operating voltage
≈0.7 mA at 3 V, 25°C, no connection to serial port
≈1 mA at 5 V, 25°C, no connection to serial port
≈5 mA at 3 V, 25°C, serial port connected
≈5.5 mA at 5 V, 25°C, serial port connected
Note: The current consumption is measured without any additional external
connections.
3 V or 5 V
Note: The operating voltage is selectable as 3 V or 5 V on the STK/EVK-PCB
by making the appropriate connections (see Figure 1–5 or 1–6,
depending on the system you have).
1–2
Page 9
1.2.2How to Install the Hardware
This section targets three main parts: the setup of the serial interface, the programming adapter, and the
power supply.
LCD and UVEPROM
The EVK is supplied with the LCD and a UVEPROM, separate from the EVK PCB. Install the EPROM and
LCD into the EVK PCB before proceeding. Refer to the STK/EVK target connectors section for the correct
LCD orientation. The STK has a one-time programmable (OTP) device mounted on the PCB.
Serial Communication
Connect the STK/EVK-PCB to the serial communications port of the PC using the 9-pin cable that is
supplied. Use the Settings/Communications. . .command to set the communication port to which the cable
is connected. The default selection is COM2.
The HyperTerminal (which uses the Terminal icon) is used to communicate to the STK/EVK MSP430 chip
via a Monitor Program that has already been downloaded into the EPROM of the chip. The HyperT erminal
settings used are: data bits—7; parity—even; stop bits—1; flow control—none.
Voltage Sources
The following four sources supply the voltage for the STK/EVK-PCB:
1.PC serial interface
Typically , the serial interface of the PC supplies the STK/EVK-PCB voltage using the 9-pin cable.
The user must determine if the serial interface can meet the electrical requirements of the
STK/EVK PCB. Some PC manufacturers do not source enough current and voltage from the
serial port to power the STK/EVK devices. If this is the case, a 9-volt battery can be connected in
parallel to the serial port.
2.3.6 V lithium battery
A battery can be assembled onto the STK/EVK that supplies the STK/EVK-PCB with power.
3.Programming Adapter
The Programming Adapter’s power supply is stabilized to 5 V (this can only be used on the EVK).
4.Target system
The power supply from a target system can be connected to the STK/EVK-PCB. A supply voltage
of 3 V to 5 V can be used.
CAUTION: Different Power Supplies
If there is more than one power supply connected, the STK/EVK is supplied
with the higher voltage, provided the data sheet supply voltage ranges are
not exceeded.
If the HyperT erminal program is running on the PC, the serial communication cable has been installed, the
proper com port is selected, and the proper voltage is supplied, the screen will look like Figure 1–3.
1–3
Page 10
MSP–STK430A320
>_
Figure 1–3. Terminal Screen
A help message is displayed on the screen automatically if the Monitor message MSP-STK430x320 is not
received by the STK/EVK control software, where x is the current revision letter.
Reset Button
NOTE: Pins for the STK Demo Program
Some pins of the MSP430 device will be used for the sensor demo program (only available on
the STK):
•A5 (connected to the sensor)
•Seg0. . .Seg13 (connected to the LCD Display)
•Com1. . .Com4 (connected to the LCD Display)
•R03. . .R33 (connected to the LCD R-Ladder)
•P0.0 (connected to the Trigger button)
•The string MSP-STK430x320 should appear in the HyperTerminal window (white background
area of the STKW95 HyperTerminal window). In addition, the LCD display on the evaluation
board (EVK or STK) should display MSP430.
•If both do not appear, simply press the reset button on the evaluation board (identified with an
RES etched next to it) one time.
NOTE:
The MSP430 evaluation board requires very low supply voltages due to its ultra-low
power consumption characteristics. In this case, the RS232 interface, or a 3.6 V
lithium battery (if installed) provides the supply voltage for the STK/EVK.
Due to PC com port differences, it may be necessary to jumper the board down to
3 V or supply an external battery . To jumper the board, refer to the diagram in the
STK/EVK T arget Connectors section, and place one jumper across the Vcc holes,
and another across the Vcc/LCD holes where the default for both of these is open.
HyperTerminal is a trademark of Hilgraeve.
1–4
Page 11
Changing the RS232 interface to another COM port (other than COM2) of a personal computer, requires
a change to the COM port assignment in the current version of the terminal emulator.
1.2.3Programming the Monitor Software Into an Erased EPROM (EVK Only)
The following steps are recommended to program the Monitor into an EPROM after it has been erased:
1.Connect the EVK-PCB to the programming adapter.
2.Connect the programming adapter to the PC.
3.Apply the power supply to the programming adapter (not included in the kit).
4.Start the Program Device software and:
– select the file mon_140.txt in the STK directory
– select with Verify
– select EPROM device
– select the correct parallel port where the adapter is connected
– click on the Program button.
For detailed information see the MSP430 Family Programming Adapter Manual.
Figure 1–4 shows the pop-up that will appear when programming the Monitor software into an erased
EPROM EVK.
Figure 1–4. Programming the Device
1–5
Page 12
1.2.4MSP-STK/EVK430x320 Target Connectors
External Supply 3–5V dc
Only Required If Stand
Alone Operation
In the HyperT erminal program, type a d to start the demo program. If the HyperT erminal program has been
closed, double click on the Sensor Demo icon to start the demo program.
LUXMETER Demo Program:
The STK Monitor includes a demo program that shows a metering application. The application hardware
consists of the light sensor, a trigger button, and a voltage reference for the analog-to-digital converter.
When the program starts, the screen displays demo and the measured light values are shown on the LCD
display (measured in irradiance). The values are updated every 5 seconds. The A on the left side of the
LCD indicates that the shown value is less than one second old. Any keystroke interrupts the demo program
and switches back to the Monitor/HyperT erminal program. If the STK is disconnected with the demo running,
the program will run until a mounted battery is discharged. To correctly exit the program push the <ESC>
key.
Voltage Reference
Trigger ButtonLight Sensor
Figure 1–9. LUXMETER Demo Program
1.2.10Executing a Program with the STK
To execute a program, write a test program or use the gs_stk1.asm file, which is located in the
C:\ADT430\STK\EXAMPLES directory. Figure 1–11 is the Getting Started demo program.
NOTE: Programming Hint
During development, a program should reside in the free RAM area (240h-3FFh for the
MSP430x320, and 272h–50Ch for the MSP430x330) making program modification during
debug phase possible. Any code written to the device’s EPROM area on the STK cannot be
erased. The stack pointer for the MSP430x33x device resides at 005DEh.
1–12
Page 19
How to use the command line parameters of the assembler:
The default command line parameters of the assembler (asm430.exe) are -z and -I. These
parameters are set in the Properties of the Assembler icon after installation. For further
information on command line parameters see the Assembly Language Tools User’s Guide .
T o change the parameters, select the ASM430 Assembler icon with one left mouse click. Click on
the file menu in the Windows Program Manager and select the Properties command. Select the
shortcut tab. Depending on the version of Windows being used, the screen will show the following
dialog on the screen:
Command
Figure 1–10. Properties
NOTE: File | Properties...
If the installation is not changed, the parameters -z and -I will be added to the target’s statement.
If the Start in: properties are adjusted to the source code directory, the path of the source file
should not be entered.
1–13
Page 20
;****************************************************************************
;Getting Started 1 Demo Program (C) TEXAS INSTRUMENTS on 2/96
Use the assembler icon in the ADT430 Program Folder to assemble the gs_stk1.asm file, which is located
in the C:\ADT430\STK\EXAMPLES directory , and is shown in Figure 1–11. Ensure that the Start in: property
of the assemble icon is set to the source directory (C:\ADT430\STK\EXAMPLES). Click on the ASM430
Assembler icon.
The following screen will appear (the version number, date, and copyright date may dif fer from that shown
below):
Figure 1–12. ASM430 Assembler Window
1–15
Page 22
Enter the source name gs_stk1 and press ENTER. This will cause the assembler to assemble gs_stk1.asm
into gs_stk1.txt. The following display will appear:
Source File
Figure 1–13. gs_stk1.asm Window Display
The assembler output file is named gs_stk1.txt. This file is created only if the assembler is invoked with the
option -z. To verify that the gs_stk1.txt file was created, check the ADT430\STK\EXAMPLES directory.
An additional listing of gs_stk1.lst is created when the option -l is used. To review the gs_stk.lst output,
double-click on the file name and view using an appropriate viewer. Figure 1–14 is a listing of gs_stk1.asm:
1–16
Page 23
MSP430 Macro Assembler Version 1.08 [09/96] Tue Jun 30 07:20:38 1998
Copyright (C) 1995, 1996 Texas Instruments Incorporated
c:\adt430\stk\examples\gs_stk1.asmPage 1
1;***************************************************************************
2;Getting Started 1 Demo Program(C) TEXAS INSTRUMENTS on 2/96
3;***************************************************************************
4
5;*** Set this variable to ’1’ for the use on the Simulator***
600SIM.set0; 1 = Simulator
7; 0 = STK/EVK
80240RAM_orig.set00240h; Free Memory startadress
903deSP_orig.set003DEh; stackpointer
10
11;––– Control register definitions
12
1300IE1.equ0h
1401IE2.equ01h
1502IFG1.equ02h
1603IFG2.equ03h
1704ME1.equ04h
1805ME2.equ05h
19
200120WDTCTL.equ0120h
2180WDTHold.equ80h
225a00WDT_wrkey.equ05A00h
23
2408GIE.equ08h
25
26;**************************************************************************
27;; Reset : Initialize processor
Next, the object file gs_stk1.txt will be downloaded to RAM of the MSP430-STK/EVK.
The PC downloads the object file gs_stk1.txt to RAM of the MSP430_STK/EVK. The PC uses the
HyperTerminal to communicate with the Monitor Program in the EVK/STK EPROM or ROM.
Windows95 (NT) provides a terminal emulator icon under Start/Programs/Accessories.
Double-clicking with the mouse on the STK430 terminal icon also starts the HyperTerminal. The STK430
icon is located under the ADT430 program group.
Serial communication is set up for the STK/EVK as needed. When the serial interface of the STK/EVK is
connected to the COM2 port of the PC, the LCD display on the STK/EVK will show MSP430, and the Monitor
in the MSP430 device will send the following string:
MSP–STK430A320
>_
1–18
Figure 1–15. Terminal Window
Page 25
Open the pulldown menu Transfer in the HyperTerminal to load the program using the RS232 into the
STK/EVK, as shown in Figure 1–16. Select the Send Text File menu item.
NOTE:
Transfer
Send Text File
MSP–STK430A320
>_
Receive text file...
V
iew Text File...
Send Binary File...
Receive Binary F
Pause
Resume
Stop
Figure 1–16. Terminal Transfer
NOTE: The help menu can be displayed by typing an h.
ile...
1–19
Page 26
Select the assembler output file gs_stk1.txt in the examples directory from the Send T ext File . . dialog box.
Figure 1–17 shows the HyperT erminal screen displaying the following data after loading gs_stk1.txt into the
STK/EVK.
In the HyperT erminal , type r0 <ENTER> to modify the program counter of the user program. The program
displays the current content of r0. Next type 0240 <ENTER> to set the start address as defined in
gs_stk1.asm. Exit the modify register mode by pressing the <ESC> key.
Each time the SP ACE bar is pressed, the program executes one single step and the program displays the
registers contents. Typing a g followed by <ENTER> causes the program to continue from the current
address stored in the program counter. Pressing the <ESC> key stops the program.
NOTE: Single Step
The single step command should only be executed if the program counter points to an
instruction in the RAM. Otherwise this command acts like a go command.
Another way to start this program is to write the start address (in this instance 0240h) into memory location
03FEh. Each time the u user command is executed or the reset button is pressed, the start address (in this
instance 0240h) is written to the user program counter. Switch to the word mode by entering a w, and then
enter m3fe and <ENTER>. Now the start address can be entered (in this instance 0240), and press
<ENTER> and <ESC> to exit. Pressing u and then g starts the program.
NOTE: Use of the examples in MSP430 Simulation Environment
If the examples are used in the MSP430 Simulation Environment, the SIM constant (located
at the top of the assembler code) must be set to 1.
1–21
Page 28
1.2.11How to Use Breakpoints
Continue the Getting Started exercise by assembling and downloading the file gs_stk2.asm in the examples
directory as described previously.
This program includes a section for the reset vector, so the program counter is initialized after the download
and each time a user performs a reset.
1.Start the program by typing g <ENTER>. The display indicates 0, then 1 on the LCD.
2.Press the <ESC> key to stop the program.
3.Type u <ENTER> to execute a user reset.
4.Set the breakpoint by typing s, and then 0264 (address) <ENTER>. This breakpoint stops the
program prior to changing the display.
5.Type s <ENTER> to stop the program. It stops prior to changing the display. Step through the
program by pressing the space bar showing how the display changes.
6.Clear the breakpoint by typing c, and then 0264 (address) <ENTER>.
Figure 1–19 shows these commands as they appear on the display .
1.2.12Accessing the Port on the MSP430x320 STK/EVK
Assemble and download the file gs_stk3.asm in the examples directory, as described previously.
Press the trigger button on the demo to start the program. Press the trigger button to toggle the display
between 0 and 1.
The following instructions are necessary:
;––– Init Port
;––– Test of Port
BIC.B#01h,P0DIR; Set P0.0 as input
BIC.B#01h,POIE; Disable P0.0 interrupt
1–23
Page 30
$ML1BIT.B#01h,P0IN; Test P0.0
JNZ$ML1; Do nothing if P0.0 low
1.2.13How to Use an Interrupt Routine
Assemble and download the file gs_stk4.asm in the examples directory, as described previously.
1.When an interrupt occurs, the program sends the contents of the program counter and status
register to the stack.
2.Next, the program branches to the starting address of the interrupt routine.
3.The interrupt routine normally ends with the RETI instruction.
4.The RETI instruction loads the data, which was saved to the stack at the beginning of the interrupt
routine, to the status register and program counter.
5.The program continues from the point of interruption.
Using interrupt routines allows the MSP430 to use low power modes. Selecting a low power mode causes
the program to stop at the current position, and an activity that causes an interrupt automatically clears the
low power mode. The interrupt continues program execution at the starting address of the corresponding
interrupt routine. The RETI loads the saved program data to the status register and program counter.
Loading the status register and program counter clears out the low power mode bits, and the program
continues with the next instruction. Figure 1–20 is the Basic Timer Interrupt routine.
DEC.Blcd_timer; decrement SW lcd-timer
JNZInt_BT_end; !0 : no action
BIC#CPUOFF,0(SP); Clear CPUoff Bit
MOV.B#lcd+ival,lcd_timer; = 0 : load again
RETI
.sect ”int_Vect”, USER_END-31
.wordRESET; no source
.wordInt_BT; Basic Timer
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; no source
.wordRESET; NMI, Osc. fault
.wordRESET; POR, ext. Reset, Watchdog
.end
Figure 1–20. Basic Timer Interrupt Routine
1–24
Page 31
Set a breakpoint at address 025Eh, and single step through the program. A longer reaction time can be
expected for any step beyond address 025Eh. At this time, the CPU is off and waiting for the Basic Timer
interrupt.
NOTE: Only two breakpoints may be set at any one time.
1.3Loading a Program Into the EPROM Via the Terminal
After debugging, the program is ready to load. The program is loaded to the EPROM for the EVK, or ROM
for the STK. The STK requires a programming voltage. The EVK requires a jumper between pins 13 and
14 of the programming connector. Figure 1–22 show the locations for the programming voltage and the
connector jumper.
1–25
Page 32
VPP -Input
Apply If
programming via serial
port
VPP fuse F250 mA
Connects to programming
adapter MSP-PRG430x
(EVK only)
Jumper for programming the EPROM
of an EVK with the Monitor
Figure 1–22. Programming Voltage and Jumper Location
To load a program into the MSP430 EPROM/ROM using the HyperTerminal, the following points must be
considered:
•The Monitor code must already be programmed into the EPROM/ROM (only the EVK is supplied
with the code for the monitor program mon_x.txt).
•The STK/EVK 9-pin D-SUB-connector must be connected to the serial interface (the default is
COM2) of the PC.
•The supply voltages of the STK/EVK must be applied by connecting the STK/EVK to the serial
interface of the PC and by connecting the programming supply voltage.
NOTE: Programming the EVK using the Serial Port
Attach a jumper between PIN 13 and PIN 14 on the Programming Adapter connector (see
Hardware Installation in Chapter 9).
If the assembled file gs_stk5.asm is downloaded, the program routines for the LCD, and the interrupt routine
of the previous example will be written into the EPROM/ROM (see sections in the code).
1–26
Page 33
;****************************************************************************
; Section in EPROM
DEC.Blcd_timer; decrement SW lcd-timer
JNZInt_BT_end; !0 : no action
BIC#CPUOFF,0 (SP); Clear CPUoff Bit
MOV.B#lcd_ival,lcd_timer ; =0 : load again
Int_BT_end
RETI
Figure 1–23. EPROM LCD and Interrupt Routine
Now these routines can be used in any other program. This section does not have to be downloaded again,
even if the STK/EVK is disconnected from the power supply .
T o load a program using the HyperT erminal, double click the terminal icon in the MSP-STK/EVK430 program
group in the Windows Program Manager. The HyperTerminal window appears as follows in Figure 1–24.
1–27
Page 34
MSP–STK430A320
>_
Figure 1–24. HyperTerminal Window
To load a program into the MSP430 using the HyperTerminal, activate the Transfers/Send Text File. . .
command as shown in Figure 1–25.
Transfer
Send Text File
MSP–STK430A320
>_
Receive text file...
V
iew Text File...
Send Binary File...
Receive Binary File...
Pause
Resume
Stop
Figure 1–25. Transfers \ Send Text File
Figure 1–26 shows the Send Text File dialog box.
1–28
Page 35
Press Open to Send TXT FileChoose your Text File
Figure 1–26. Send Text File Dialog Box
Figure 1–27 represents a burn fail screen. If an error occurs during the programming of the EPROM, the
screen shows the message burn failed at XXXX. Where XXXX is the address where the programming cycle
failed the first time.
In the gs_stk6.asm example, in the examples directory, only the addresses of the routines in the EPROM
are labeled. This supports easy use of program sections in the EPROM.
;****************************************************************************
; Addresses in EPROM
;****************************************************************************
PrepLCD.equEPROM_orig; EPROM Address of PrepLCD
;––– clear LCD
show_clr.equEPROM_orig+50h; EPROM Address of show_clr
This chapter describes the syntax conventions and the available commands of the Monitor Program.
2.1Syntax Conventions
•The numbers in brackets [ ] are optional.
•x is a hexadecimal address.
•n is the hexadecimal number of bytes to show.
•i is the hexadecimal register number.
•Only the r, m, and e commands expect <ENTER> or <ESC> commands.
•The <ESC> key provides a keyboard interrupt for all command inputs except m.
•The half-duplex UART prevents keyboard interrupts while entering a large number of bytes to
show the results of an action.
•The registers are named in hexadecimal format from R0 to RF.
•All addresses or memory/register contents must be entered in hexadecimal mode. Entering
zeros in the MSB is optional.
•Errors in address or memory/register contents in the terminal input must be corrected by
re-entering all four hexadecimal digits. The leading (MSB) zeros are optional.
•The Arrow, Insert, Delete, or Backspace keys can not be used to change an incorrect terminal
input.
2.2Memory Organization
T o use some commands, it is necessary to know the memory locations and their functions (see Figure 2–1).
In memory locations 000h to 0FFh, only the byte mode is possible. In memory locations 100h to 1FFh, only
the word mode is possible. Memory locations 010h to 0FFh are reserved for 8-bit peripheral modules, and
the locations between 100h and 1FFh are reserved for 16-bit peripheral modules.
FFFFh
FFE0h
FFDFh
C000h
03FFh
0200h
01FFh
0100h
00FFh
0010h
000Fh
0000h
INT. VECTOR
16 KB EPROM
512 B RAM
16 Bit Peripheral Modules
8 Bit Peripheral Modules
Special Function Register
MSP430x320
Figure 2–1. Memory Organization
FFFFh
FFE0h
FFDFh
8000h
05FFh
0200h
01FFh
0100h
00FFh
0010h
000Fh
0000h
INT. VECTOR
32 KB EPROM
1 KB RAM
16 Bit Peripheral Modules
8 Bit Peripheral Modules
Special Function Register
MSP430x330
2–1
Page 38
2.3Commands
hThe h command displays the Help Command screen shown in Figure 2–2 with the available
commands.
Enter h at the command prompt
>Monitor Commands
h help
b,w byte, word mode
i,w monitor, user reset
r[x] inspect registers
mx[n] inspect memory
ex n eprom erase check
@x .. q load program
d run DEMO
sx set breakpoint
cx clear breakpoint
g go (free run)
<space> single step
<ESC> exit command
>_
2–2
Figure 2–2. Help Command
Page 39
b,w The b and w commands shown in Figure 2–3 switch to byte or word indication mode. The two
indication modes are only important for the memory inspect command m. The Monitor completes the
entered command (b
iThe i command, shown in Figure 2–4, initializes the entire monitor program. This command performs
a software reset of the STK/EVK, but is only possible if the monitor is still running. If the contents of
memory location 3DEh are AA55h, the i command will start the user application. Turn off the hardware
supply voltage to return control to the monitor. This clears the bit-pattern AA55h.
Enter i at the command prompt
>init
MSP–STK430A320
Figure 2–4. Initializing the Terminal Program Command
2–4
Page 41
uThe u command, shown in Figure 2–5, sets the user PC to the start vector of the loaded user program.
This performs a user reset of the application. In this example, the start vector of the user application,
located at address 03FEh, is 0300h.
Entering the command with the hexadecimal register number r[i] <ENTER> as shown in Figure 2–7, results
in displaying only the contents of the dedicated register i.
Type r5 <ENTER> at the command prompt
>r5
reg 0005 : 0010 _
Figure 2–7. Register Specified Command
NOTE: Modification of the Registers R1, R3, and R4
The Monitor Program does not allow the modification of registers R1, R3, and R4. R1 is the
stack pointer and can not be modified because of the internal program structure of the monitor.
R3 is the constant generator register and therefore cannot be modified. R4 is internally used
by the monitor, therefore, modification of R4 by the user application code will overwrite the
correct function in the monitor program and cause improper operation.
2–7
Page 44
Figure 2–8 shows the procedure for changing data in a register. Write new data into register r[i] by pressing
<ENTER> and the program displays the next register.
Type r5 <ENTER> at the command prompt
Type the new desired register contents and press <ENTER>
Figure 2–10 shows the proper way to change incorrect entries. Using the Arrow, Delete or Insert keys as
inputs causes unpredictable behavior. After entering an incorrect register content, the entire input should
be entered again. Another method is to press <ESC> and to enter the r[i] command again.
NOTE:
The ENTER key must never be pressed after entering an incorrect input.
The address x shown above as 220 must be entered to define the memory location. The number n, shown
above as 20, is optional. It defines the number of memory bytes that are to be displayed. Entering the m
command without n allows the memory contents at address x to be displayed or modified.
NOTE: Interrupt.
Viewing large memory areas will take some time because the output function to display memory
contents cannot be interrupted while the UART is operating in the half duplex mode.
2–11
Page 48
Figure 2–12 shows how to modify memory contents. Modify the memory by typing in new data and pressing
<ENTER>. The program displays the next memory location. If no modification is necessary press
<ENTER>. T o exit the memory command (mx) press the <ESC> key. Pressing <ENTER> toggles through
memory locations, displaying each new location after <ENTER>.
Switch to byte indication mode
Switch to word indication mode
Show and modify memory location 0300h in byte mode
Show and modify memory location 0300h in word mode
Enter aa then <ENTER> to modify memory
Enter bbcc then <ENTER> to modify memory
>init
MSP–STK430A320
>byte
>m0300
mem 0300 : 31 aa
mem 0301 40
>word
>m0300
mem 0300 : 40aa bbcc
mem 0302 : 0400
>m0300
mem 0300 : bbcc
>_
2–12
Press <ESC> here
Show only one memory location 0300h in word mode
Figure 2–12. Memory Modification
Page 49
To revise an incorrect terminal input, perform the following functions as shown in Figure 2–13. Using the
Arrow, Delete or Insert keys as inputs causes unpredictable behavior. After entering an incorrect register
contents, the entire input should be entered again. Another method is to press <ESC> and enter the m
command again. Never type <ENTER> after entering an incorrect input.
Start the memory mode
Incorrect terminal input
Correction
Press <ESC>
>init
MSP–STK430A320
>byte
>m@#$% 20300 2
mem 0300 : 31 40
>m@#$% 2
>m0300 2
mem 0300 : 31 40
>_
View memory contents
Figure 2–13. Revised Memory Modification
2–13
Page 50
@xThe @x command loads program/data section(s), byte by byte, into the RAM/EPROM. A program
algorithm detects the correct download section (in the RAM or EPROM) and runs automatically . The
transfer can be made by using a keyboard or by file transfer (pull-down menu Transfers/Send Text
File in Hyperterminal program). If download is performed manually, it can be terminated with a q
keystroke. Normally the data associated with the load command is a content of linker or
assembler-generated program/data files.
Figure 2–14 is an example of the format of such a program/data file:
The @x command sets the memory-modification address to the address where program/data files are
stored. All code lines following the @x command represent data in byte format. These bytes will be copied
sequentially to the specified section address. The q command terminates the section input and returns the
control back to the Monitor Program.
NOTE: Programming an EPROM
While programming the EPROM, be sure that the file being used has the correct section
addresses and contains the correct program/data. Programming an EPROM location once will
prevent a second programming at this location in the STK. For more information see the
Hardware Installation section in this manual.
2–14
Page 51
ex nThe EPROM erase check (ex n) command verifies that the EPROM is empty. The EPROM is empty
if the contents of all EPROM-memory locations are FFh. The x represents the starting address to
verify that the EPROM has been erased. The n portion of this command will show the number of
bytes that have been erased. The Monitor ceases checking the EPROM if a memory location other
than FFh is detected and displays that memory location as shown in the Figure 2–15.
Enter mC040 20 <ENTER> to start memory mode (to show 20h)
Check if there is memory space at C040h for 20h Words
Memory location C040h is not erased and is displayed
>mC040 20
mem c040 : ffff ffff ffff ffff ffff ffff ffff ffff
mem c050 : 4035 000f 43c5 0030 8315 23fc 4130 ffff
>eC040 20
mem c050 : 4035>
Figure 2–15. EPROM Erase Check Command
2–15
Page 52
sThe s command allows a breakpoint to be set. The program supports the capability of having two
breakpoints. Breakpoints may be set only if the program is in RAM. Typing an s shows the
breakpoints that are currently set. Figure 2–16 shows how to enter the location of the breakpoint.
Set a breakpoint by Typing ‘s’
Enter the location of the breakpoint: 24e
MSP–STK430A320
>Set Bkpt 0000 0000 24e
Figure 2–16. Location of a Breakpoint Command
Both breakpoint addresses are displayed. A breakpoint address that contains all zeros indicates that no
breakpoint is set. Enter the address to set a breakpoint. Pressing the <RETURN> key activates the
breakpoint at that address.
2–16
Page 53
The address of the two breakpoints should not be identical. Only two breakpoints are supported, a third
breakpoint cannot be set. In order to set another breakpoint, one breakpoint has to be cleared first with the
c command. Figure 2–17 shows the breakpoint after entry.
To set a breakpoint type s
Enter the location of the breakpoint: 24e <ENTER>
>init
MSP–STK430A320
>Set Bkpt 0000 0000 24e
>Set Bkpt 024e 0000
Press <ESC> here
Figure 2–17. Set a Breakpoint Command
2–17
Page 54
cThe c command is used to clear a breakpoint. Typing c shows the set breakpoints, as shown in
Figure 2–18.
Clear a breakpoint by typing a ‘c’
>Clr Bkpt 024e 0000
Figure 2–18. Clearing a Breakpoint Command
To clear one of the breakpoints (other than zero), it is necessary to enter the associated address. Typing
the <ENTER> key after entering the address clears the breakpoint. See Figure 2–19.
To clear a breakpoint type c
To clear a breakpoint enter the location: 24e <ENTER>
2–18
>Clr Bkpt 024e 0000 24e
>set Bkpt 0000 0000
Press <ESC> here
Start set breakpoint mode by typing s to show the cleared breakpoint
Figure 2–19. Clearing a Breakpoint Location
Page 55
gThe g command starts/restarts the user application that is loaded into RAM. The system retrieves
the start vector of a user’s application from memory location (3FEh on the 320 STK/EVK, 5FEh on
the 330 EVK) if a new program is loaded, or after executing a PUC command or a user reset.
Otherwise, the program execution continues with the actual PC (R0). Return to the Monitor occurs
after pressing any key on the keyboard. The g command functions as stated if the user application
is not running in an interrupt routine (GIE=0 if interrupt nesting is not allowed), and the user
application has not disabled the GIE bit.
The Monitor Program uses the R4 register internally to return data from the user application to the
Hyperterminal. Modifications to the value stored in R4 will result in unexpected behavior of the Monitor
Program. The Monitor command r, to change the register contents, is not supported for R4. The register R4
can be modified by the user application code. Consequently , the user should exercise caution when using
this register.
It is possible to interrupt the user application by pressing the ESC key on the keyboard. This works only if
the GIE bit has not been cleared. One exception is possible in spite of a cleared GIE flag. If the user
application runs on a breakpoint, program execution will branch to the Monitor as the program runs.
Problems may occur if the user application uses most of its time in interrupt routines. While the application
is servicing an interrupt, a new interrupt can only occur if the GIE bit has been set. The GIE bit is set only
if the first interrupt routine explicitly sets it within the routine itself, thereby allowing for nested interrupts.
Starting the user application with the Monitor causes the Monitor Program to set the GIE bit. If the GIE-bit
was reset before in the user application, it will remain set. This ensures the availability of the RS232
communication but influences the user’s software application. The particular interrupts can be enabled with
their associated interrupt flags.
3.2The Instruction CALL R4
In the user application, it is possible to return to the Monitor with the instruction CALL R4. The monitor should
be started prior to this so that the contents in R4 are valid and to initialize the Monitor.
A single step should not be executed over the CALL R4 instruction because this will cause unpredictable
behavior of the Monitor. The following code is an example that uses the instruction CALL R4.
NOTE:
Execute the single step command only if the program counter points to an instruction in
the RAM.
The Monitor Program uses eighteen bytes of RAM, from address 200h to 212h, within the RAM area of the
MPS430x32x (which ranges from 200h to 3FFh for the MSPx32x family , and 200h to 5FFh for the MSPx33x
family). The user application should not use this memory area.
The Monitor Program needs no stack while running the user application. If the user application returns to
the Monitor Program using a breakpoint, single step, or keyboard interrupt, an additional stack size of 32h
bytes is needed for the Monitor Program. This Monitor Program stack is always set up on the top of the user
stack. When returning to the user application, the Monitor Program clears the entire user stack. If the user
program is inactive and the Monitor Program is running, 50 bytes are put onto the stack. The stack pointer
shown in Figure 3–3 reflects the application situation, not the actual Monitor stack pointer. In these 50 bytes,
all register data valid in the application program is saved to be restored when the user application is
reactivated. Returning to the user application, the 50 bytes used are freed, and the stack pointer is pointing
to the user application.
3–2
Page 59
In most cases, it is efficient to initialize the user stack which is allowed to grow (downwards) until it reaches
the address 270h (26Fh–32h=23Eh). Thus, the resulting size of the maximum user stack is 16Dh
(3DCh–272h=16Ah) on the MSP430x325 family and 360h (5DCh–272h = 36Ah) on the MSP430x33x family .
Interrupt
Vectors
Identification Bit Pattern
Maximum Program,
Stack and Data Size
of User Application
Is 3FEh – 272h
Stack Needed From
ROM Monitor
Temporary
Burn Routine
RAM Area Always Reserved
From ROM Monitor
RAM Area 272h–3FEh for
the MSP430x320
3FEh
3E0h
3DEh
3DCh
272h
23Eh+32h = 270h
23Eh
23Dh
214h
212h
200h
Interrupt
Vectors
Identification Bit Pattern
Maximum Program,
Stack and Data Size
of User Application
Is 5FEh – 272h
Stack Needed From
ROM Monitor
Temporary
Burn Routine
RAM Area Always Reserved
From ROM Monitor
RAM Area 200h–5FFh for
the MSP430x330
5FEh
5E0h
5DEh
5DCh
272h
23Eh+32h = 270h
23Eh
23Dh
214h
212h
200h
Figure 3–2. RAM Area 272h to 3FEh
3–3
Page 60
The user application data is located within the RAM area from 272h to 3FEh (5FEh for 33x). The locations
used statically (200h to 214h) and dynamically (stack) by the Monitor Program limit the size of the available
RAM. Due to limited size, two memory configurations are recommended as shown in Figure 3–3.
User application inactive,
User application active
3FEh
Interrupt Vectors
3E0h
Monitor Program active
single step, breakpoint,
<ESC>
3FEh
Interrupt Vectors
3E0h
Identification Bit Pattern
SP
Address Range for
Program, Stack and
Data of User
Application is 3DCh
to 214h
NOTE:
The User
Application Does
Not Set the Stack
Pointer SP
RAM Area Always Reserved
for ROM Monitor
3DEh
3DCh
214h
212h
200h
Identification Bit Pattern
Stack Used by
Application
Stack Needed From
SP
ROM Monitor, 50 Bytes
Maximum Program,
Stack and Data Size
of User Application
Is Reduced by 50
Bytes, After Return
to the Monitor
Program
RAM Area Always Reserved
For ROM Monitor
3DEh
214h
212h
200h
NOTE:
The identification bit pattern determines if the monitor code or a user’s code (program)
is executed after a power-up or hardware reset (PUC). See Section 5.2. The temporary
burn routine addresses are allocated for the EPROM burn routine, which must run in the
RAM. When data is written into the EPROM (program memory), code in the EPROM
cannot be executed. Therefore, the burn program has to be in RAM (loaded from the
EPROM) so it can be executed.
Figure 3–3. RAM Area 200h to 3FFh for the MSP430x32x Family
In most cases it is efficient not to initialize the user-stack, but to use the stack pointer set by the monitor .
3–4
Page 61
3.5Writing Data Into the EPROM
When data is written into the EPROM address range, software code is written into RAM locations 214h to
23Dh. All addresses 1000h or higher are assumed to be EPROM. After the write operation is completed,
the code in the RAM is no longer needed. The code is written into RAM when a write into the EPROM address
range is performed. Ensure that the data in these locations are not needed when the EPROM write code
is temporarily loaded into those locations.
A write into EPROM can be done when an application program is executed, or when the monitor is active.
For example, when the mx[n] command is executed:
No write to EPROM active
Available RAM for
User Application
RAM Area Always Reserved
for ROM Monitor
214h
212h
200h
Available RAM for
User Application
Temporary
Burn Routine
RAM Area Always Reserved
for ROM Monitor
23Eh
23Dh
214h
212h
200h
Figure 3–4. Temporary Burn Routine in the MSP430x32x RAM Area
User application data for the MSP430X33x family should be located within the RAM area (from 200h to
5FFh). The locations used statically (200h to 214h), and dynamically (stack) by the Monitor Program limit
the size of the available RAM.
NOTE:
The Identification Bit Pattern defines if the monitor code or a user’s code (program) is
executed after a power-up or hardware reset (PUC). See Section 5.2. The TemporaryBurn Routine user’s addresses are allocated for the EPROM burn routine which must
run in the RAM. When data is written into the EPROM (program memory), code in the
EPROM can not be executed. Therefore, the burn program has to be in the RAM (loaded
from the EPROM so it can be executed).
3–5
Page 62
3–6
Page 63
4 Treatment of Interrupts
This chapter describes the special treatment of interrupts in the Monitor environment.
4.1Use of Interrupts in the Monitor Environment
The interrupt structure of the MSP430 is fully supported by the terminal program with one exception, the NMI
interrupt has the same interrupt vector as the RESET interrupt.
There are no restrictions on the interrupt flags, but certain restrictions apply to the interrupt vectors. It is
impossible to program the interrupt vectors located in the address range FFECh to FFFEh, because they
are preprogrammed in the EPROM area and can not be modified. The Monitor Program has the flexibility
to allow a second set of interrupt vectors in the RAM address range 3E0h to 3FEh (5E0h–5FEh for the
MSP430X33x family) as shown in Figure 4–1. The Monitor Program branches program execution if an
interrupt occurs to the associated interrupt vector located in the second interrupt vector address range. The
instruction used is an absolute BR command (i.e., BR &0FFEAh for the ADC interrupt). Therefore, during
the use of the Monitor Program, the interrupt vectors are moved by an amount of FC00h below their normal
location.
Reset
NMI
P0.0 Interrupt
P0.1 Interrupt
Watchdog Interrupt
ADC Interrupt
Basic Timer Interrupt
Port0.2 to 0.7 Interrupt
FFFEh
Interrupt
FFE0h
Reset
NMI
P0.0 Interrupt
P0.1 Interrupt
Watchdog Interrupt
ADC Interrupt
Basic Timer Interrupt
Port0.2 to 0.7 Interrupt
Figure 4–1. Monitor Interrupts for the MSP430x32x Family
03FEh
Interrupt
03E0h
4–1
Page 64
Figure 4–2 shows the handling of a P0.0 interrupt for the MSP430X32x family. For the MSP430X33x,
replace address 03FAh with 05FAh.
P0.0 Interrupt
FFFAh
XXXX
XXXXBR & 03FAh
03FAh
YYYY
YYYY Is The Start Address
Of The Interrupt Service Routine
YYYY
Figure 4–2. P0.0 Interrupt Example
The number of cycles an interrupt is additionally delayed in the Monitor Program depends on the type of
interrupt received.
T able 4–1. Type of Interrupt
TYPE OF INTERRUPTDELAY (NUMBER OF CYCLES)
RESET14
IN_P0110
All other interrupts3
NOTE: Status Register Setting Exception After Interrupts
After entering the interrupt service routine of a Reset or a P0.1 interrupt, the zero-bit Z
and the carry-bit C in the status register SR are not reset as expected.
The interrupt vectors and the associated interrupt vector addresses of the MSP430E325 device are shown
in Table 4–2 (or Table 4–3 for the MSP430E33x).
4–2
Page 65
T able 4–2. Interrupt Vectors for the MSP430x32x Family
Timer Port‡Maskable3E8h4
I/O Port P2P2IFG.07
I/O Port P1P1IFG.07
Basic TimerBTIFGMaskable3E2h1
I/O Port 0P0.27IFG
†
Multiple source flags
‡
Timer Port interrupt flags are located in the module
INTERRUPT
FLAG
†
†
NMIIFG
†
OFIFG
††
††
ADCIFGMaskable3EAh5
†
†
†
SYSTEM
INTERRUPT
Reset3FEh15, highest
Nonmaskable
Nonmaskable
Maskable3F6h11
Maskable3F2h9
Maskable3F0h8
Maskable3E6h3
Maskable3E4h2
Maskable3E0h0, lowest
WORD
ADDRESS
3FCh14
PRIORITY
4–3
Page 66
4–4
Page 67
5 Half Duplex Monitor Software UART
The Monitor Program provides several functions for handling serial data communications using the RS-232
interface. The user can call these functions by using the associated vectors in the terminal program. Use
the absolute address mode to call these functions. For example, a possible syntax for preparing the half
duplex software UART to receive characters is:
CALL&0FFD6h ;in address FFD6h the vector of RX_Prep is stored
another possible syntax is:
RX_Prep .equ0FFD6h
CALL&RX_Prep ;in address FFD6h the vector of RX_Prep is stored
The STK/EVK software UART cannot be used for binary transfers for the following two reasons:
•The protocol has only seven data-bits.
•A zero cannot be received because this is the detection scheme for no-character-received.
The vectors related to these functions are stored in the following locations (see Table 5–1):
T able 5–1. Function/Vector
FUNCTION NAMEVECTOR ADDRESSFUNCTION PURPOSE
TX_Word0FFD0hTransmit 1 space and a four digit hex number in R11
TX_Char
TX_Table
RX_Prep
TX_Prep
INT_RXTX0FFDAhInterrupt service routine for receive and transmit
Ret_Mon0FFDChReturn to the Monitor with a br Ret_Mon statement
†
Calling TX_Char, TX_Table, TX_Prep, or RX_Prep enables the GIE flag in the status register (SR). The GIE bit remains
set even if it was disabled before calling these routines.
†
†
†
†
0FFD2hTransmit 1 char in TXData (20Eh)
0FFD4hTransmit table (string address should be in R11)
0FFD6hPrepare halfduplex software UART for receive
0FFD8hPrepare halfduplex software UART for transmit
5.1Transmission Parameters of the Software UART
The transmission parameters of the MSP-STK/EVK430x320 and EVK430x330 are:
•2400 Baud
•1 start-bit
•7 data-bits
•1 parity-bit (even)
•1 stop-bit
The RTS and DTR pins of the serial port must be set to high to provide the supply voltage for the STK/EVK
if no battery is assembled. This is done automatically in the Windows HyperTerminal program. If other
communication software is used, the specified pin levels must be met.
5.2Identification of Bit Pattern AA55h
The interrupt service routine INT_RXTX is used for the receive and transmit function. If another INT_RXTX
service routine is being used, the identification bit pattern AA55h must be stored in memory location 3DEh
(5DEh for the MSP430x33x family). Otherwise, the INT_RXTX service routine will never branch program
execution to the vector located in the user interrupt vector table. This pattern remains in memory until it is
changed by the program or the power is switched off.
5–1
Page 68
The flow chart in Figure 5–1 I illustrates the entry point of the INT_RXTX interrupt service routine:
INT_P0.1
noyes
Identification ?
Contents Of Memory
Location 3DEh
= AA55h
yes
Receive/Transmit Interrupt Service
TXRX
Half Duplex Software
UART Prepared For
Receive or Transmit ?
(PREPRX or PREPTX)
P0.1 Interrupt Continues Program Execution
Upon The User Interrupt Vector Stored In
Memory Location 3F8h
User Interrupt Service Routine Branches
To INT_RXTX Service Routine From
ROM-Monitor ?
(First Instruction = CALL &0FFDAh ?)
Start Of Monitor Interrupt
Service Routine INT_RXTX
Routine
no
User Interrupt
Service Routine is
Continued
Interrupt Service Handler For TransmitInterrupt Service Handler For Receive
Figure 5–1. Identification of Bit Pattern AA55h for the MSP430X32x Family
5–2
Page 69
NOTE: Init Command
Do not use the Monitor init command out of the terminal emulator while the bit pattern
AA55h is stored in memory location 3DEh on the MSP430X32x, or 5DEh on the
MSP430X33x family . Otherwise, the user application with the reset vector stored at 3FEh
(5FEh for the MSP430X33x family) will be started.
To use the INT_RXTX interrupt service routine, first load the P0.1 interrupt-vector, which is responsible for
the timer interrupt used in the software UART . The P0.1 interrupt vector is stored in the user interrupt vector
table at address 3F8h.
The following code is an example of the user interrupt vector table and the associated branch to the
INT_RXTX routine.
UART:br &0FFDAh
RESET:br &0FFFEh
.sect “Int_Vect”,03E0h ; Use 05E0h for the MSP430X33x family
.word RESET; Port0, bit 2 to bit 7
.word RESET; Basic Timer
.word RESET; no source
.word RESET; no source
.word RESET; no source
.word RESET; EOC from ADC
.word RESET; no source
.word RESET; no source
.word RESET; no source
.word RESET; no source
.word RESET; Watchdog/Timer, Timer mode
.word RESET; no source
.word UART; Address of UART handler
.word RESET; P0.0
.word NMI; NMI, Osc. fault
.word RESET; POR, ext. Reset, Watchdog
end
In this example, all other interrupts will continue program execution at the reset vector of the terminal
program stored at address FFFEh.
NOTE: Identification Pattern AA55h
The identification pattern must be programmed as the last word of the complete download. To
assure this, the section containing only the identification, is the last section in the source file.
5–3
Page 70
5.3Special Treatment of <ESC> in the Software UART
The software UART treats a received ESC character in two different ways:
•The software UART receives the ESC character and stores it at address 210h. The condition,
therefore, is that bit 0 in memory location 200h is reset.
•The software UART receives the ESC and returns back to the Hyperterminal. The condition is
that bit 0 in memory location 200h be set.
End of ROM-Monitor
Interrupt Service Routine
Contents of
yesno
Memory Location
3DEh is AA55h for
MSP430X32x
(or 5DEh is AA55h
for MSP430X33x)
yes
yes
The Return From Interrupt
is By-Passed
Into ROM-
Monitor
Normal Return Out of
INT_RXTX
Interrupt
Service
no
no
Bit 0 in Memory
Location 200h Set ?
Received Character
is <ESC>
Figure 5–2. Special Treatment of ESC
BIC#01h,&200h; reset bit 0, because no special treatment of <ESC> is
; wanted
BIS#01h,&200h; reset bit 0, because special treatment of <ESC> is
; wanted
NOTE: Memory Location 200h
Only bit 0 in memory location 200h may be modified. A modification of the higher bits may result
in an unpredictable behavior of the terminal program.
5–4
Page 71
5.4Transmitting One Character
To transmit one character, copy AA55h to memory location 3DEh, or memory location 5DEh for the
MSP430X33x family . Store the character to transmit in RAM-location 020Eh.
TX:MOV#0AA55h,&03DEh; &05DEh for MSP430X33x
MOV.B#‘a’,&TX_Data; put char to TX_Data
Call the function TX_Char to transmit the character stored at location 20Eh.
call&0FFD2h; call of TX_Char
The function TX_Char includes the call of TX_prep implicit which prepares the half-duplex software UART
to receive. Therefore, it is not necessary to call TX_Prep before calling TX_Char.
5–5
Page 72
The following code in Figure 5–3 is an example of transmission of the single character s.
In Figure 5–3, the endless loop at the end of the program can be interrupted by pressing <ESC> in the
HyperT erminal. If no special treatment of <ESC> is required in the software UART , bit 0 in RAM location 200h
must be cleared. This bit is the ESC-active-flag and allows itself to return back to the Hyperterminal when
pressing the ESC key.
Conditions for implementation:
•Correct setting of the P0.1 interrupt vector in the user interrupt vector table
•The first statement of the user interrupt handler is an absolute branch to the INT_RXTX interrupt
service routine.
•GIE is enabled.
•The halfduplex software UART is set up to receive.
NOTE: Clear the Bit Pattern AA55h
Do not try to load a program while the bit pattern AA55h is stored at address 3DEh on
the MSP430x32x, or 5DEh on the MSP430x33x. To load a new program, clear the bit
pattern AA55h at address 3DEh on the MSP430x32x, or 5DEh on the MSP430x33x, or
switch off the STK/EVK for a short time to clear the RAM.
5.5Transmitting a String
The first step to transmit a string is to move the bit pattern AA55h to memory location 3DEh on the
MSP430x32x, or 5DEh on the MSP430x33x. The address of the string must be stored in register R1 1.
A character received using the RS232 interface is written from the INT_RXTX interrupt routine into memory
location 210h. After performing a reset, this memory location contains zeros. Each byte (not equal to zero)
received is stored in memory location 210h.
The content of memory location 210h is checked to determine whether or not a byte has been received. After
reading the byte, this location must be cleared. The next-received character will overwrite memory location
210h with a new byte.
The following code is an example of receiving a character and transmitting the same character back.
This chapter describes how to use interrupt vectors stored in the EPROM. The interrupt vectors are stored
in EPROM so they are not lost when power is removed.
6.1The Identification Bit Pattern After a Reset
The reset start-up sequence checks the contents of memory location E9DEh to see if its contents are equal
to AA55h. If the memory location contents equal AA55h, the EPROM interrupt vector table with addresses
ranging from E9E0h to E9FEh is copied to the interrupt table in the RAM locations 3E0h to 3FEh on the
MSP430x32x, or 5E0h to 5FEh on the MSP430x33x family, and the key for the software UART is set to
AA55h to switch the monitor off. If the contents of memory location E9DEh are equal to 0000h, the next set
of interrupt vectors, located at 22h below the previous location, is tested like the first set previously
described. If the valid identification is set to AA55h after each power up or hardware reset, the user program
starts and the EPROM monitor is switched off. The only way back to the monitor is an indirect branch to
Ret_Mon (0FFDCh). The user program code implements a branch, as well as the condition for the branch.
6–1
Page 78
Set Location of Identification
noyes
Identification ?
Contents of Identification
Address = AA55h
Reset
Address Pointer to E9DEh
Decrement Identification
Address Pointer By 22h
Identification ?
Contents of Identification
Address = 0000h
Copy EPROM Interrupt Vectors
And Identification AA55h
To RAM Interrupt Vectors
6–2
Start Monitor
Jump To New Reset Vector
Address In RAM
yes
Emergency Return
(Optional – User Defined
yes: BR Ret_Mon)
To Monitor ?
Figure 6–1. Identifying AA55h After Reset
NOTE:
It is important that the emergency return to the Monitor routine works properly and
has been tested in RAM before burning it into the EPROM. If the actual
identification address contains address AA55h, the Monitor will NEVER start again.
Be sure to program the key as the last step in the evaluation of a program, after all
errors have been fixed.
Page 79
The following example demonstrates how to implement and test the emergency come-back to the monitor
routine:
1.Set the variable DVLP to 0 after the routine has been successfully tested in RAM. The variable
TRIAL indicates the number of interrupt tables that have been burned. The last necessary input
is the start address BEGIN.
2.Insert the address where the program is stored. To find a free section in EPROM, use the m or
the e command.
3.The terminal is switched off and the program enters an endless loop after burning the program
and executing a reset, or after starting it with the go command.
4.To come back to the monitor, press and hold down the demo button and press the button.
;****************************************************************************
; Demo for Emergency Burn-over of already written ID = AA55h
;****************************************************************************
DVKO.set1; Development = 1, Final = 0
TRIAL .set1; Progressing trial number )start=1)
BEGIN .set0C000h; Startaddress of (new) code in EPROM
;––– definition of testpin
pin.set01h; testpin is P0.0
P0DIR .set12h; Port 0 direction control register
P0IN.set10h; Port 0 input register
;––– ddfine working sections
.if DVLP =1
.text 00240h; code in RAM during development
.else
.text BEGIN; code in EPROM at final run
.endif
;––– test routine is waiting for low at testpin
start
bic.b#pin, P0DIR; testpin is input
bit.b#pin, P0IN; test testpin
jnzuser_prg; jump to user program if testpin = 1
clr003DEh; clear ID in RAM (005DEh on MSP430X33x)
br0FFDCh; branch indirect to Monitor
;––– insert here the start up of your user program
user_prg
jmpuser_prg; Dummy endless loop
;––– define reset vector in RAM for development
.sect“RAM_RES”, 03FEh ; 05FEh on MSP430X33x
6–3
Page 80
.wordstart
;––– additionally define reset vector in EPROM if final version
Program the identification pattern as the last word of the download. T o assure this, the section
containing the identification should be the last section in the source file.
The following code is an example of the EPROM user interrupt vector table and the associated key for its
activation.
The MSP430 is well suited for the development cycle. The Monitor Program provides the commands s and
c to set and clear breakpoints, and SPACE to perform a single step execution in the RAM area for these
devices.
MonitorProgrammedProgrammed in only one device. After erasing the device, the
LCDAssembledNot assembled
Sensor demoHardware assembledHardware not included
Two windowed unbearable devices PMS430E325FZ or
PMS430E337HFD
monitor program (mon_140.txt for the MSP–EVK430x320, and
mon_160.txt for the MSP–EVK430x330) in the STK directory
must be programmed again. See Programming Adapter Manual.
A–1
Page 86
A–2
Page 87
Mouser Electronics
Authorized Distributor
Click to View Pricing, Inventory, Delivery & Lifecycle Information:
Texas Instruments: MSP-EVK430S320MSP-EVK430S330
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.