DSP Starter Kit User Guide
DSP Starter Kit User Guide
User’s Guide
Running Title—Attribute Reference
IMPORTANT NOTICE
Texas Instruments (TI) reserves the right to make changes to its products or to discontinue any
semiconductor product or service without notice, and advises its customers to obtain the latest
version of relevant information to verify, before placing orders, that the information being relied
on is current.
TI warrants performance of its semiconductor products and related software 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”).
Inclusion of TI products in such applications is understood to be fully at the risk of the customer.
Use of TI products in such applications requires the written approval of an appropriate TI officer.
Questions concerning potential risk applications should be directed to TI through a local SC
sales office.
In order to minimize risks associated with the customer’s applications, adequate design and
operating safeguards should be provided by the customer to minimize inherent or procedural
hazards.
ii
Preface
Notational Conventions
dsk3a filename
dsk3a is a command. The command invokes the assembler and has one
parameter, filename, which is required. When you invoke the assembler,
you supply the name of the file that the assembler uses as input.
iv
Notational Conventions/Information About Warnings
The symbol is required for the .set directive and must begin in column 1.
The value is also required.
.entry [value]
The following books describe the TMS320C3x and related support tools. To
obtain a copy of any of these TI documents, call the Texas Instruments Litera-
ture Response Center at (800) 477–8924. When ordering, please identify the
book by its title and literature number.
vi
If You Need Assistance
Trademarks
AT is a trademark of International Business Machines Corp.
viii
Contents
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Describes the key features and provides an overview of the TMS320C3x DSP Starter Kit.
1.1 Key Features of the DSK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.2 DSK Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
ix
Contents
x
Contents
C Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
Defines acronyms and key terms used in this book.
Contents xi
Running Title—Attribute Reference
Figures
1–1 TMS320C3x DSK Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
2–1 Connecting Your Parallel Printer Port Cable and Transformer Into Your DSK Board . . . . 2-4
2–2 DOS Command Setup for the DSK Environment (Sample autoexec.bat File) . . . . . . . . . . 2-6
2–3 Basic Debugger Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
3–1 Basic Debugger Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
3–2 DSK Software Development Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
4–1 TMS320C3x DSK Functional Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
4–2 Parallel Port Control Register (0x37A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4–3 Parallel Port Status Register (0x379) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4–4 DSK Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
4–5 Data-Packet Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
4–6 Single-Step Flow Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4–7 Primary Communication Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
4–8 Secondary Communication Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
4–9 Control Register Bit Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
7–1 DISASSEMBLY Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7–2 CPU REGISTER Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
7–3 MEMORY Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6
7–4 COMMAND Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7–5 Monitor Information Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
B–1 TMS320C3x DSP Starter Kit (DSK) Circuit Board Dimensions . . . . . . . . . . . . . . . . . . . . . . B-2
xii
Running Title—Attribute Reference
Tables
4–1 Single-Step Pipeline Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
4–2 Primary Communications Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
5–1 Indirect Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
5–2 ANSI C Math Library Functions Supported by the DSK Assembler . . . . . . . . . . . . . . . . . . 5-12
5–3 Operators Used in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
5–4 Summary of Assembler Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15
6–1 Assembler Directives Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
7–1 Summary of Debugger Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7–2 Editing Command Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7–3 Command-Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7–4 Command-Line Buffer Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7–5 Running Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7–6 Displaying and Changing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
7–7 Managing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
7–8 Loading Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
7–9 Performing System Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
7–10 Function Key Shortcuts for DISASSEMBLY Window Active . . . . . . . . . . . . . . . . . . . . . . . . 7-13
7–11 Function Key Shortcuts for CPU Window Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
7–12 Function Key Shortcuts for MEMORY Window Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
7–13 Function Key Shortcuts for COMMAND Window Active . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Contents xiii
Running Title—Attribute Reference
Examples
2–1 Port Selection Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
3–1 File rand.asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
4–1 Initialize the Serial Port Global Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
4–2 Setting the TA and TB Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
6–1 Sections Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
xiv
Chapter 1
Introduction
This chapter provides an overview of the TMS320C3x DSP Starter Kit (DSK).
The ’C3x DSK is a low-cost, simple, high-performance stand-alone application
development board that lets you experiment with and use TMS320C3x DSPs
for real-time signal processing. The DSK has a TMS320C31 on board to allow
full-speed verification of the TMS320C3x code. The DSK also gives you the
freedom to build new boards, create your own software on a host PC, down-
load the software to the DSK, and run the software on the DSK board. The
supplied debugger is windows-oriented, simplifying code development and
debugging capabilities.
Topic Page
1-1
Key Features of the DSK
- Analog data acquisition via the TLC32040 analog interface circuit (AIC ):
- Standard RCA plug connectors for analog input and output that provide
a direct connection to microphone and speaker
Note:
Jumper and header are not installed.
- Expansion connectors, which route all the TMS320C31 pins for use with
DSK daughterboards
1-2
DSK Overview
All of the signals for the ’C3x are routed to expansion connectors. The expan-
sion connectors include four 32-pin headers, an 11-pin jumper block, and a
12-pin XDS510 header.
The TLC32040 AIC interfaces to the TMS320C3x serial port. A jumper block
allows removal of this connection to route the serial port to a DSK daughter-
card that you supply. Two RCA connectors provide analog input and output on
the board.
ÁÁÁÁÁÁ
Á
Á ÁÁÁÁÁÁÁÁÁÁ ÁÁÁÁÁÁ
ÁÁÁÁÁÁ
Á ÁÁÁÁÁÁÁÁÁÁ ÁÁÁÁÁ
ÁÁÁÁÁÁ
I/O
expansion Analog
Á
ÁÁÁÁÁÁ ÁÁÁÁÁÁÁÁ Á
ÁÁÁÁÁÁÁÁÁÁ
connector TLC32040 in
AIC
Á
ÁÁÁÁÁÁÁÁÁÁ ÁÁÁÁÁ
TMS320C31–50 out
A23–A0
ÁÁÁÁÁÁ
Á Á
ÁÁÁÁÁÁÁÁÁÁ
Á
D31–D0
ÁÁÁÁÁÁ
Á ÁÁÁÁÁÁÁÁÁÁ
Control
Á
ÁÁÁÁÁÁ
Parallel
port ÁÁÁÁÁÁÁÁÁÁ
ÁÁ
Emulation port
Á
ÁÁÁÁÁÁ ÁÁÁÁÁÁ
ÁÁ
interface
ÁÁÁÁÁÁ
ÁÁÁÁÁÁ
XDS510
MPSD port
See Appendix B, DSK Circuit Board Dimensions and Schematic Diagrams, for
an explanation of the basic DSK components.
Introduction 1-3
Chapter 2
This chapter describes how to install the DSP Starter Kit (DSK) on a PC system
running under DOS.
Topic Page
2-1
What You Need
Hardware checklist
Power requirements A UL Class II power supply with a 2.1-mm power jack connector that
provides 7–12 Vdc or 6–9 Vac and at least 400–1500 mA, which is
common to most wall-mounted DC transformers. For isolated wall
mount supplies, the polarity of the 2.1 mm power jack does not
matter. Laboratory-type power supplies with case grounds are not
recommended since they can create ground loops and possibly
create a short circuit through the DSK full-wave rectifier.
Note:
You may want to use the DSK’s on-board power supply and regulators
for external circuits. If so, do not overload the circuit. External loads will
cause the regulators to operate at a higher temperature. Loads >50 mA
are not recommended.
If you make modifications or you are using an external laboratory power
supply, be sure you connect it to the DSK correctly; the DSK is not
warranted after you make modifications to it.
To minimize risk of electric shock and fire hazard, the power supply
adapter should be rated UL class 2. The adapter and personal
computer providing energy to this product should be certified by
one or more of the following: UL, CSA, VDE, TUV.
2-2
What You Need
Software checklist
Note:
Other applications for the DSK can also be downloaded from the TMS320
BBS or Internet FTP site. See the If You Need Assistance subsection on
page vii, for the Internet address.
2) Connect your parallel printer port cable to the parallel communication port
(LPT) on your PC. This port can be identified by its size and pin type, which
should be the female matching equivalent to the DSK. (RS232 ports which
use DB25 connectors use the opposite pin configuration).
3) Plug the parallel printer port cable into the DSK DB25 connector.
4) Plug 7–12 Vdc or 6–9 Vac power supply into the DSK power supply
connector. See Figure 2–1 for details.
Figure 2–1. Connecting Your Parallel Printer Port Cable and Transformer Into Your DSK
Board
PAL 22V10 System clock
Power
supply
LED connector
RCA jack
analog out
RCA jack
analog in
TLC32040
Plug your printer cable into this socket (DB25 female)
Note:
Some manufacturers of plug-in cards may also use DB25 connectors that
appear to be of the same type. If this is the case, be sure to check the PC
configuration thoroughly before continuing.
2-4
Step 2: Installing the DSK Software / Step 3: Modifying Your config.sys File
1) Make a backup copy of the product disk. (If necessary, refer to the DOS
manual that came with your computer).
2) On your hard disk or system disk, create a directory named dsktools. This
directory will contain the DSK assembler and debugger software. To
create this directory, enter:
md c:\dsktools
3) Insert your product disk into drive A. Copy the contents of the disk using
the following command:
copy a:\*.*c:\dsktools\*.*/v
Once you edit your config.sys file and add the line, invoke the file by rebooting
the PC (press the reset switch, or turn off the PC’s power and turn it on again).
You can accomplish this by entering individual DOS commands, but it’s
simpler to put the commands in your system’s autoexec.bat file. The general
format for doing this is:
PATH=C:\dsktools;pathname2 ;pathname3
This allows you to invoke the debugger without specifying the name of the
directory that contains the debugger executable file.
If you are modifying your autoexec.bat file and it already contains the PATH
statement, simply include ;C:\dsktools at the end of the statement as shown
in Figure 2–2.
Figure 2–2. DOS Command Setup for the DSK Environment (Sample autoexec.bat File)
DATE
TIME
ECHO OFF
PATH statement PATH=c:\dos;c:\dsktools
CLS
If you modify the autoexec.bat file, be sure to invoke it before invoking the
debugger for the first time. To invoke this file, enter:
autoexec
2-6
Step 5: Verifying the Installation
After entering the dsk3d command, you should see a display similar to the one
shown in Figure 2–3.
Note:
When the communications kernel is first loaded, the on-chip timers are initial-
ized causing the LED to cycle through several colors. The sequence is red–
yellow–green–yellow–red, etc.
If you see a display similar the one shown in Figure 2–3, you have correctly
installed your DSK board, assembler, and debugger. If you see the display
shown in Example 2–1, then your software or cable may not be installed prop-
erly. Go through the installation instructions again and make sure that you
have followed each step correctly; then reenter the dsk3d command above.
Installation errors
If you still do not see the debugger display, one or more of the following condi-
tions may be the cause:
You may have used an incorrect communication port (LPT1 versus LPT2).
Your printer port cable and connectors may not be connected snugly.
Your power transformer may not be plugged in on both ends. If the DSK
is receiving power, then the LED will illuminate either red or green.
Some operating systems do not use conventional AT I/O port addresses when
mapping port names to addresses. For example, an EISA PC or IBM PS/2
might assign port 0x3BC as LPT1 instead of LPT3. If this is the case, you
should use LPT3 to start the DSK, since the DSK works from a physical
address instead of the port name LPTx. The last three lines of Example 2–1
show the operating system’s lookup table (located at RAM address
0000 0040) that maps physical addresses to port names. This may help you
to determine which ports are in use and which name is associated with each
port for a particular address. The information in the lookup table in
Example 2–1 may not be accurate since network and operating system soft-
ware also uses this table for redirecting printer output.
2-8
Step 5: Verifying the Installation
Overview of a Code
Development and Debugging System
The DSP Starter Kit (DSK) lets you experiment with, and use a DSP for real-
time signal processing. The DSK gives you the freedom to create your own
software to run on the board as is, or to build new boards and expand the
system in any number of ways.
The DSK assembler and debugger are software interfaces that help you to
develop, test, and refine DSK assembly language programs.
Topic Page
The debugger can run and debug your code on an actual ’C3x DSP (as op-
posed to a simulator, which uses a PC to only simulate a DSP).
3-2
Description of the DSK Debugger
Figure 3–1 identifies several debugger display features. When you invoke the
debugger by typing in dsk3d, you should see a display similar to this one (it
may not be exactly the same, but it should be close).
F1 Help F2 REG40 F3 FLOAT F4 Srce F5 Run F6 DispBP F7 ClrAll F8 SStep F9 Grow F10 FStep
assembler
source
assembler
executable
debugger
file
DSK
target
system
The assembler translates DSK assembly language source files into machine
assembler
language object files for the TMS320C3x family of processors. Only the most
essential assembler features are incorporated. This is not a COFF assembler,
although executable object files created by the TI TMS320 floating-point DSP
assembly language tools will also load and run on the DSK.
The main purpose of the development process is to produce a module that can
debugger
be executed in a DSK target system. You can use the debugger to refine and
correct your code.
3-4
Getting Started
1) Create a source file to use for the walkthrough; call it rand.asm. You do not
need to enter the information following a semicolon; such information is
comments to help you understand what the program is doing.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
; RAND.ASM ;
; This example shows nested loops with a call to a random number ;
; within the inner loop. ;
; ;
; NOTE: This file can be loaded either by using the debugger or a ;
; bootloader. This example does not use 0x809800 and 0x809801 since ;
; the bootloader uses these locations for stack space. ;
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
.start ”CODE”,0x809802 ; Start assembling CODE section here
.sect ”CODE” ;
.entry SAMPLE ; Debugger entry point
;––––––––––––––––––––––
SAMPLE ldp @stack ; Load a data page
ldi @stack,SP ; Load a stack pointer
;––––––––––––––––––––––
ldi 0,R0 ; Start with SEED = 0
ldi 0,R1 ; Inner loop counter
ldi 0,R2 ; Outer loop counter
;––––––––––––––––––––––
OUTER ldi 3,RC ; Start ’OUTER’ loop
rptb INNER ; Repeat block ’INNER’ (RC+1) times
call RAND ; Call function
addi 1,R1 ; Count ’INNER’ loops
INNER addi 1,R2 ; Count ’OUTER’ loops
b OUTER ; Do it again!
;––––––––––––––––––––––––––––––––––––––––
; Fast 32 bit random number generator
;––––––––––––––––––––––––––––––––––––––––
RANDX: ldi @SEED,R0 ; Calculate RAND(SEED)
RAND: mpyi @A,R0 ; Calculate RAND(R0)
addi @C,R0 ;
sti R0,@SEED ; Result is returned in R0
rets ;
;––––––––––––––––––––––
A .word 0107465h ; Constants needed for RAND
C .word 0234567h ;
SEED .word 0 ;
;––––––––––––––––––––––––––––––
stack .word $+1 ; Begin stack here
.end
3) Now you are ready to debug your program. Enter the following command
to invoke the debugger:
dsk3d
3-6
Chapter 4
Functional Overview
The TMS320C3x DSK hardware and software work together to create a low-
cost development platform that lets you develop real-time signal processing
applications. In addition to performing full-speed verification of your
TMS320C3x code, the DSK has expansion headers that allow you to build new
daughterboards to expand your system.
This chapter details the functionality of the hardware and the software.
Topic Page
4-1
DSK Hardware Interface
The programmable array logic (PAL) determines when the ’C31 is accessing
the host interface by using the STROBE A23, A22, A21, and A20 signals to
decode the address of the ’C31.
The PAL provides one input (TRI) that disconnects the host interface by tri-
stating the PAL INT2 and READY signals. The PAL provides five address
decode outputs: USER_IOR, USER_IOW, USER_IO, USER_RAM,
USER_BOOT; and three outputs: READY, INT2, and EN signals. When the
DEMO signal is pulled high, two of the address decode outputs, USER_IO and
USER_BOOT, drive the tri-color LED.
The bus transceivers buffer data between the PC parallel printer port and the
’C31 parallel bus. The host interface supports two types of transfers:
The 8-bit bidirectional mode allows faster transfers on parallel printer ports
that support bidirectional transfers.
Unidirectional printer ports support an 8-bit transfer from the host to the
’C31 while supporting 4-bit transfers from the ’C31 to the host.
4-2
DSK Hardware Interface
VCC
INIT RESET
(RESET) LTICPAL22V10Z–25
13 INT2
H1
ÁÁ ÁÁÁÁÁ
ÁÁ
NC
ÁÁ ÁÁÁÁÁ
2
PSTROBE D Q0 D Q1
ÁÁ
(HPSTB) READY
Á
HPIA TRI
Á Á
USER_IOR A20
USER_IOW A21
USER_RAM Address A23
decode
Á Á
A23
USER_IO 15 0 STROBE
Á 1
ÁÁ
Á Á ÁÁ ÁÁ TRI
Á Á ÁÁ
19 0
10
TCLK1
Á ÁÁ
USER_BOOT 1 11
VCC DEMO
ÁÁ
EN DIR R/W
8
ÁÁ
ÁÁ
PD7–PD0 D7–D0
74HCT245
ERROR
(HPACK)
ÁÁ
EN
DIR
ÁÁ
SELECT
PAPER 4
ACK
BUSY
A IN ÁÁ74HCT245
IN+ MCLK
IN– RESET
TCLKO
XFO
DR DR
DX DX
Á
FSX FSX
Á
A OUT OUT– FSR FSR
OUT+ SCLK CLKX
TLC32040 CLKR
Host communications
The host communicates with the ’C31 through the parallel printer port. The PC
manipulates the parallel port’s signals by writing to and reading from the host’s
parallel port control and status registers. Figure 4–2 and Figure 4–3 show the
parallel port control and status register bit fields used by the DSK host soft-
ware. (The labels below the printer port signal names refer to signal names as
used by the DSK board as shown in Figure 4–1.)
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁ
Á
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁ
Á
Figure 4–2. Parallel Port Control Register (0x37A)
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ Á
ÁÁÁÁÁ
7 6 5 4 3 2 1 0
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁ
Á
DIR0 X DIR1 INT SLCTIN INIT AUTOFD PSTROBE
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁ
Á
RESET HPSTB
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁ
Á
W R/W W R/W W R/W
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
Á
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
Á
Figure 4–3. Parallel Port Status Register (0x379)
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ Á
ÁÁÁÁÁ
7 6 5 4 3 2 1 0
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
Á
BUSY ACK PAPER SELECT ERROR ACK X X
ÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁ
ÁÁÁÁÁ
Á
D3 D2 D1 D0 HPACK
The host initializes the ’C31 by pulsing the INIT signal (writes a 0 followed by
a 1 to the INIT bit field of the parallel port control register). This signal resets
the ’C31 and activates the bootload mode. The host then downloads your pro-
gram or the communications kernel to the ’C31. The parallel port is mapped
into the ’C31 memory to the address range 0xFFF000–0xFFFFFF, as shown
in Figure 4–4, page 4-7.
The host sends data to the ’C31 in the following way:
1) The host writes the byte to be transmitted to the I/O-mapped area of the
host’s parallel port data lines (I/O address 0x378 for LPT 1).
2) The host drives the HPSTB signal low and waits for an acknowledgement.
The HPSTB signal interrupts the ’C31 by pulsing the INT2 signal, indicat-
ing that the host is requesting the transfer of a packet. The INT2 signal is
needed only for the initial packet transfer request and is ignored during
subsequent packet requests.
3) The ’C31 starts a one-wait-state read access to location 0xFFF000. The
PAL decodes this address as the host interface active (HPACK) signal,
drives the host’s ERROR signal low, and drives the ’C31’s READY signal
high. This prevents the ’C31 from completing its read access. The host
uses the ERROR (HPACK) signal to acknowledge that the ’C31 is “locked”
and waiting to receive the data.
4-4
DSK Hardware Interface
4) The host drives the HPSTB signal high, indicating to the ’C31 that the data
is ready. The PAL detects the rising edge of HPSTB and drives the ’C31’s
READY signal low, unlocking (freeing) the locked-bus access, and con-
cluding the ’C31 read cycle.
5) This process is repeated until all four bytes are transferred (least signifi-
cant byte first). At each transfer, the ’C31 pieces the bytes together to form
a 32-bit word.
1) The host waits for the HPACK signal, indicating that the ’C31 understands
the host request for a packet transfer.
3) When the host receives the HPIA signal, it drives PSTROBE low and the
host reads a byte or 4-bit nibble, depending on whether a bidirectional par-
allel printer is present in the host.
4) The host drives the HPSTB signal high, indicating to the ’C31 that the data
was read. The PAL detects the rising edge of HPSTB and drives the ’C31’s
READY signal low, concluding the ’C31 write cycle. This completes the
’C31 read cycle.
5) This process is repeated until all four bytes or eight nibbles are transferred
(least significant byte first). During each transfer, the host pieces the bytes
together to form a 32-bit word.
Note:
During the bootload process, the ’C31 does not read the third and fourth
bytes of the first 32-bit word. The bootloader acts as if it is reading from an
EPROM and skips these bytes.
Variable ADC and DAC sampling rate with 14-bit precision at 20 000 sam-
ples per second
The DSK connects the TLC32040 AIC to the ’C31 serial port through a header
and 100 Ω isolation resistors. The header lets you disconnect the AIC and use
the ’C31’s serial port in the daughterboard. Two additional pins from the ’C31
control resetting and clocking signals to the AIC:
The ’C31’s TIMER0 pin drives the master input clock to the AIC.
The ’C31’s XF0 signal resets the AIC.
The AIC’s analog input and output are connected to RCA plugs. These signals
are line-level compatible (+/–3 V peak) and can be connected to audio
line-level inputs and outputs.
The output can also be connected directly to a speaker, but it does not have
a significant output level as the output drive is limited by the AIC output driver
and a series isolation resistor. For best results, use an external amplifier or
high impedance speaker, such as a headphone.
Note:
If the AIC is used with parameters outside the tested range, the AIC perfor-
mance may be degraded from that specified in the data sheet. See the
TLC32040 Data Sheet (SLAS014) for more information.
4-6
DSK Hardware Interface
External
USER_BOOT
400000h
7FFFFFh Boot 2
800000h
Reserved
807FFFh (32K)
808000h
Peripheral bus
memory-mapped registers
(6K internal)
8097FFh
809800h
RAM block 0
(1K word)
8098FFh
On-chip 809C00h
ÇÇÇÇÇÇÇÇÇ
RAM block 1
internal
(1K word)
RAM 0
ÇÇÇÇÇÇÇÇÇ
and 809F00
Kernel
ÇÇÇÇÇÇÇÇÇ
RAM 1 The kernel, interrupt,
(2K total) 809FC0h and trap tables
ÇÇÇÇÇÇÇÇÇ
809FC1h occupy the last 256
Interrupt and trap branches words of RAM 1.
809FFFh
80A000h
External USER_RAM
0x0BFFFFFh
0x0C00000h
External USER_IO
0x0DEFFFFh
0x0E00000h
External HPI
(non interlocking)
0x0EFFFFFh
0x0FFF000h Boot 3
External HPI
(interlocking)
0x0FFFFFFh
Data packets
The host and the ’C31 communicate by exchanging packets of data.
Figure 4–5 shows the structure for data packets. The data-packet headers
(shaded section) typically consist of four fields: command, data-stream length,
target address, and target index. This header is followed by the data stream
as shown in Figure 4–5. The header fields are described as follows:
Command directs the handling of the packets. See the Commands sec-
tion, page 4-9, for more information.
Target address points to the memory location where data is read from or
written to.
Target index post-increments the value of the target address after a read
or write of a single data item.
Command
Data-stream length
Target address
ÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁ
Data stream
4-8
DSK Communications Kernel
Commands
When the ’C31 receives an interrupt from the host (INT2), the ’C31 saves the
current state of the CPU and then receives a packet. Once the ’C31 receives
the packet, the communications kernel analyzes the command entry in the
header to direct the handling of the packet. The command entry provides the
low-level routines necessary to communicate with the host and debug the sys-
tem. The communications kernel supports these commands:
XWRIT Write a block of data from the host to the DSK. This command
takes data-stream-length items from the host and writes them
into the ’C31’s memory location pointed to by the target address.
The target address is incremented by the target index after each
write operation.
XREAD Read a block of data from the DSK to the host. This command
reads data-stream-length items from the ’C31’s memory location
pointed at by the target address and sends them to the host. The
target index increments the target address after each read opera-
tion.
XCTXT Get the ’C31 context save buffer address.
XRUNF Restore the context of the CPU and execute code until a
breakpoint is encountered or a halt command is issued. This
command is used for debugging.
XSTEP Restore the context of the CPU, execute a single instruction, and
then save the context of the CPU. This command is used for
debugging.
XHALT Save the context of the CPU and wait for a new command. This
command is used for debugging.
Debugging functions
Several debugging functions are implemented within the communications ker-
nel by building upon the low-level communications commands. The kernel’s
debugging functions can execute as a background task that is integrated into
the system. Debugging does not halt the system, but allows concurrent execu-
tion of other tasks. Debugging is fast and efficient and requires only a host in-
terface, although it does consume some amount of processor memory and
bandwidth.
4-10
DSK Communications Kernel
Interrupts
The communications kernel implements breakpoints by replacing the code at
the desired location with a TRAPn opcode. When the CPU encounters a
TRAP, the context-save routine is invoked, the CPU enters spin mode, writes
an acknowledge to the host, and waits for a new command. While in spin
mode, the CPU can receive new interrupts.
ÁÁÁÁÁÁÁ
Figure 4–6. Single-Step Flow Diagram
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Context restore
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
@_PC,R5 ; return to PC from TOS return
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ldi
and CINT2,IF ; Clear/Poll INT2 before SSTEP or RUNF
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
tstb 4,IF ; Set XINIT1 interrupt
bnz $–3 ;
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ldiu @_ST,ST ; restore Status
BUD R5 ;
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
or 2000h,ST ; turn on INT’s
@_R5,R5
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ldi ;
ldiu @_DP,DP ; restore DP
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁ
Fetch one user
ÁÁÁÁÁÁÁ
opcode
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁ
XINT1 occurs
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁ
Context save
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁ Send trap
ÁÁÁÁÁÁÁ
acknowledge to host
ÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁ Wait in spin loop
4-12
DSK Communications Kernel
2 or 2000h,ST BUD R5
5 Set global interrupt enable USER1 ldp @_DP,DP ldi @_R5,R5 or 2000h,ST
Table 4–1 describes the pipeline flow that sets the XINT1 interrupt and
branches to your code. This table shows that the activities in the pipeline are
coordinated so that the code is fetched at the same time global interrupts are
enabled. In this way, the interrupt is placed in the pipeline right after fetching
the second instruction. This instruction is discarded and the pipeline is filled
with the interrupt service routine (ISR).
Note:
Another way of interpreting CPU interrupts is to treat them as a special kind
of opcode that is inserted into the pipeline. Instructions that are in the pipeline
before the interrupt occurs must complete execution.
4-14
TLC32040 AIC Initialization
Timer Initialization. The following ’C31 assembly code initializes the tim-
er in clock mode with a timer period of 1. The following code initializes timer
0 to generate a square wave (clock mode) on the TCLK0 pin at a frequency
of 6.25 MHz (timer period = 1):
TGCR0 .set 808020h ; Timer 0 global control register
TCNT0 .set 808024h ; Timer 0 counter register
TPR0 .set 808028h ; Timer 0 period register
TIMVAL .word 3c1h ; Timer global control register value
ldp @TGCR0 ; Set Data Page
ldi 0h,R4 ; Initialize R4 to zero
ldi 1h,R0 ; Initialize R0 to 1
sti R4,@TGCR0 ; Reset timer0
sti R0,@TPR0 ; Store timer0 period
sti R4,@TCNT0 ; Reset timer0 counter
ldi @TIMVAL,R7 ; Load timer control value
sti R7,@TGCR0 ; Start timer 0
A period of zero is not allowed in pulse mode. If the timer is run in clock mode,
the resulting output is a square wave with a frequency of half that of pulse
mode. A period of zero is allowed in this mode resulting in a 12.5-MHz clock.
For a detailed description of the ’C31 serial port, see the TMS320C3x User’s
Guide.
The ’C31 assembly code in Example 4–1 initializes the serial port global con-
trol register (SGCR0) in the following manner:
Issuing transmit and receive resets
Enabling receive and transmit interrupts
Setting 16-bit receive and transmit transfers
Setting FSX and FSR, CLKX and CLKR active low
Setting continuous mode
Setting variable data rate transfers:
Refer to the example code supplied with the DSK for help on setting up the AIC.
4-16
TLC32040 AIC Initialization
To ensure that the switched-capacitor lowpass and bandpass filters meet their
transfer function characteristics, the frequency of the clock inputs of the
switched-capacitor filter must be 288 kHz; otherwise, the upper and lower cut-
off frequencies of the low-pass and band-pass are scaled accordingly.
Equation 4–2 shows the switched capacitor filter frequency,
For example, using this equation for an 8-kHz sampling rate with a MCLK of
6.25 MHz, results in a Tx counter A of 11 [A = MCLK/(2 SCF)]. Using
Equation 4–2, Tx counter B results in 36 [B = MCLK/(2 A Conver-
sion_Frequency)].
To initialize the AIC’s Tx counter A and B registers, you must send a primary
communication followed by a secondary communication (explained in the Pri-
mary communications subsection below, and Secondary communications
subsection, on page 4-18.) Primary communications load values into the D/A
while secondary communications load A/D internal registers, such as the con-
trol register, Tx counters A and B, and Rx counters A and B.
Primary communications
Primary communications have a data value in the 14 MSBs (D15–D2) of data
and a mode selection in the two LSBs (D1–D0). This format is shown in
Figure 4–7.
ÁÁÁ
ÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
Figure 4–7. Primary Communication Data Format
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁ
ÁÁ
ÁÁÁ
D15
ÁÁÁ
ÁÁÁ
ÁÁÁ
D14
ÁÁ
ÁÁÁ
ÁÁÁ
D13
ÁÁÁ
ÁÁÁ
ÁÁ
ÁÁÁ
D12
ÁÁÁÁÁ
ÁÁÁ
ÁÁÁ
ÁÁÁ
D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁ
D/A converter value
mode
selection
The AIC sends the data value to the D/A converter and enables one of the
modes shown in Table 4–2 depending on the two LSBs.
The second and third modes use the TA’ and RA’ registers to advance or slow
down the sampling frequency by shortening or lengthening the sample period.
This is particularly useful in modem applications. It can also enhance the sig-
nal-to-noise performance, perform frequency-tracking functions, and gener-
ate nonstandard modem frequencies.
Secondary communications
Secondary communication follows a primary communication that has the two
LSBs set to 11. This secondary communication programs the AIC by loading
the A, A’, B, or control registers. Figure 4–8 shows the secondary communica-
tion data format. The TA, RA, TB, and RB values are unsigned. The TA’ and
RA’ values are in signed 2s-complement format. The control register enables
and disables auxiliary inputs, bandpass filters, and so forth.
X X X X X X X X Control register 1 1
4-18
TLC32040 AIC Initialization
The assembly code in Example 4–2 sets the TA and TB registers of the AIC.
This code transmits a 16-bit word to the AIC and then waits until the transmit
interrupt is generated by the serial port. Four commands are transmitted start-
ing with a 0, then the TB and RB values, followed by the TA and RA values,
and finally the control word. TA and RA values should be the last values trans-
mitted, since they change the AIC sample rate. By transmitting these values
last, the sample rate is not changed until the AIC receives the last program
word. In this way, very high sample rates can be achieved. Each command
transmits three 16-bit words: a primary communication, a secondary commu-
nication, and a 0-data word.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; LOOPAIC.ASM is an example program which shows how to initialize and use
; the TLC32040. The analog output (DAC output) is either a ramp signal
; (RAMPEN=1) or a loopback of the analog input (RAMPEN=0).
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
.start ”AICTEST”,0x809802 ; Start assembling here
.sect ”AICTEST” ;
;––––––––––––––––––––––––––––––––––––
; Define constants used by program
;––––––––––––––––––––––––––––––––––––
RAMPEN .set 1 ; Set to 1 to generate ramp at AOUT
T0_ctrl .set 0x808020 ; TIM0 gl control
T0_count .set 0x808024 ; TIM0 count
T0_prd .set 0x808028 ; TIM0 prd
S0_gctrl .set 0x808040 ; SP 0 global control
S0_xctrl .set 0x808042 ; SP 0 FSX/DX/CLKX port ctl
S0_rctrl .set 0x808043 ; SP 0 FSR/DR/CLKR port ctl
S0_xdata .set 0x808048 ; SP 0 Data transmit
S0_rdata .set 0x80804C ; SP 0 Data receive
TA .set 12 ; AIC timing register values
TB .set 15 ;
RA .set 12 ;
RB .set 15 ;
GIE .set 0x2000 ; This bit in ST turns on interrupts
;––––––––––––––––––––––––––––––––––––
; Define some constant storage data
;––––––––––––––––––––––––––––––––––––
A_REG .word (TA<<9)+(RA<<2)+0 ; A registers
B_REG .word (TB<<9)+(RB<<2)+2 ; B registers
C_REG .word 10000011b ; control
S0_gctrl_val .word 0x0E970300 ; Serial port control register
; values
S0_xctrl_val .word 0x00000111 ;
S0_rctrl_val .word 0x00000111 ;
RAMP .word 0 ; RAMP count value
ADC_last .word 0 ; Last received ADC value
4-20
TLC32040 AIC Initialization
;****************************************************
; Begin main code loop here
;****************************************************
main or GIE,ST ; Turn on INTS
ldi 0x34,IE ; Enable XINT/RINT/INT2
b main ; Do it again!
;–––––––––––––––––––––––––––––––
DAC2 push ST ; DAC Interrupt service routine
push R3 ;
.if RAMPEN ; If RAMPEN=1 assemble this code
ldi @RAMP,R3 ;
addi 256,R3 ; Add a value to RAMP
sti R3,@RAMP ;
.else ; Else assemble this
ldi @ADC_last,R3 ;
.endif ;
andn 3,R3 ;
sti R3,@S0_xdata ; Output the new DAC value
pop R3 ;
pop ST ;
reti ;
;–––––––––––––––––––––––––––––––
ADC2 push ST ;
push R3 ;
ldi @S0_rdata,R3 ;
sti R3,@ADC_last ;
pop R3 ;
pop ST ;
reti ;
;*****************************************************;
; The startup stub is used during initialization only ;
; and can be safely overwritten by the stack or data ;
;*****************************************************;
.entry ST_STUB ; Debugger starts here
ST_STUB ldp T0_ctrl ; Use kernel data page and stack
ldi 0,R0 ; Halt TIM0 & TIM1
sti R0,@T0_ctrl ;
sti R0,@T0_count ; Set counts to 0
ldi 1,R0 ; Set periods to 1
sti R0,@T0_prd ;
ldi 0x2C1,R0 ; Restart both timers in pulse mode
sti R0,@T0_ctrl ;
;–––––––––––––––––––––
ldi @S0_xctrl_val,R0;
sti R0,@S0_xctrl ; transmit control
ldi @S0_rctrl_val,R0;
sti R0,@S0_rctrl ; receive control
ldi 0,R0 ;
sti R0,@S0_xdata ; DXR data value
ldi @S0_gctrl_val,R0; Setup serial port
sti R0,@S0_gctrl ; global control
;======================================================;
; This section of code initializes the AIC ;
;======================================================;
AIC_INIT LDI 0x10,IE ; Enable only XINT interrupt
andn 0x34,IF ;
ldi 0,R0 ;
sti R0,@S0_xdata ;
RPTS 0x040 ;
LDI 2,IOF ; XF0=0 resets AIC
rpts 0x40 ;
LDI 6,IOF ; XF0=1 runs AIC
;–––––––––––––––––––––
ldi @C_REG,R0 ; Setup control register
call prog_AIC ;
ldi 0xfffc ,R0 ; Program the AIC to be real slow
call prog_AIC ;
ldi 0xfffc|2,R0 ;
call prog_AIC ;
ldi @B_REG,R0 ; Bump up the Fs to final rate
call prog_AIC ; (smallest divisor should be last)
ldi @A_REG,R0 ;
call prog_AIC ;
b main
;–––––––––––––––––––––––––––––––
prog_AIC ldi @S0_xdata,R1 ; Use original DXR data during 2 ndy
sti R1,@S0_xdata ;
idle
ldi @S0_xdata,R1 ; Use original DXR data during 2 ndy
or 3,R1 ; Request 2 ndy XMIT
sti R1,@S0_xdata ;
idle ;
sti R0,@S0_xdata ; Send register value
idle ;
andn 3,R1 ;
sti R1,@S0_xdata ; Leave with original safe value in DXR
;–––––––––––––––––––––
ldi @S0_rdata,R0 ; Fix the receiver underrun by reading
rets main ; the DRR before going to the main loop
;****************************************************;
; Install the XINT/RINT ISR handler directly into ;
; the vector RAM location it will be used for ;
;****************************************************;
.start ”SP0VECTS”,0x809FC5
.sect ”SP0VECTS”
B DAC2 ; XINT0
B ADC2 ; RINT0
4-22
Host Software
DSK software also includes an assembler and a debugger. These are de-
scribed in Chapter 5, Using the DSK Assembler, and Chapter 7, Using the DSK
Debugger.
Description The getmem routine reads a block of data from the ’C31 memory.
Description The putmem routine writes a block of data into ’C31 memory.
4-24
Host Software SSTEP_CPU, RUN_CPU, HALT_CPU
Description The SSTEP_CPU routine single-steps one instruction by restoring the context
of the CPU, executing one instruction, and then saving the CPU context. This
command places the CPU in command mode.
Arguments None
Description The RUN_CPU routine executes instructions starting at the program counter
obtained from the CPU context save area and ending at a breakpoint, if one
has been set.
Arguments None
Description The HALT_CPU routine halts the execution of instructions. This command
places the CPU in command mode and saves the CPU context.
Arguments None
Description The GET_DEBUG_CTXT routine retrieves the ’C31 context save location
starting address. The context address value is placed in the global variable
DEBUG_CTXT.
4-26
Host Software DSK_reset, input_rdy, recv_long_byte
DSK_reset Reset
Description The reset routine resets the DSK by toggling the INIT signal.
Arguments None
Description The input_rdy routine indicates that the DSK is ready to receive.
Arguments None
Description The recv_long_byte routine receives a 32-bit value in four 8-bit data transfers
(to be used only in bidirectional parallel printer ports).
Description The recv_long routine receives a 32-bit value in eight 4-bit data transfers (to
be used in bidirectional and unidirectional parallel printer ports).
Description The xmit_long routine transmits a 32-bit value in four 8-bit data transfers (to
be used in bidirectional and unidirectional parallel printer ports).
Description The xmit_byte routine transmits an 8-bit value in a single data transfer (to be
used in bidirectional and unidirectional parallel printer ports)
4-28
Host Software LF
LF Load File
Description The Load_File function performs several tasks depending on the enumerated
TASK given to it. DSK and COFF file formats are distinguished by the exten-
sion of the file. The enumerated TASK list is defined in the file DSK_COFF.H.
An ASCII hexadecimal file format that contains the bootloader header informa-
tion and raw data is also supported. Since the header information defines
where and how long a section is, this file format can be used to either bootload
or load files. This file format is easily converted to ROM files with a user-de-
fined post processor.
After initializing communications with the DSK, the Load_File function then
loads the desired application.
4-30
Chapter 5
This chapter explains how to use the DSK assembler and describes valid DSK
source files.
Topic Page
5-1
Creating DSK Assembler Source Files
.text
start ldi 2h, IOF ; Pull AIC into reset
ldi 0h, T4 ; Clear R4
ldp SGCR0
sti R4, @SGCR0 ; Reset serial port
ldi @SINIT1, R7 ; Load initialization value 1 into R7
sti R7, @SPCX0 ; Initialize FSX/DX/CLKX control reg.
sti R7, @SPCR0 ; Initialize FSR/DR/CLKR control reg.
ldi @SINIT0, R7 ; Load initialization value 0 into R7
sti R7, @SGCR0 ; Enable RINT and 16–bit transfers
sti R4, @DTX0 ; Transmit 0
Your source statement can contain four ordered fields. The general syntax for
source statements is as follows:
Labels are optional; if you use them, they must begin in column 1.
One or more blanks must separate each field. Note that tab characters are
equivalent to blanks.
Comments are optional. Comments that begin in column 1 can begin with
an asterisk or a semicolon (* or ;), but comments that begin in any other
column must begin with a semicolon.
5-2
Creating DSK Assembler Source Files
The mnemonic field follows the label field. The mnemonic field cannot start in
column 1, or it is interpreted as a label. The mnemonic field can contain one
of the following opcodes:
Machine-instruction mnemonic (such as ADDI, MPYF)
Assembler directive (such as .data, .set, .entry)
If you have a label in the first column, a space, colon, or tab must separate the
mnemonic field (opcode) from the label. For example:
;==================================================
.start ”AICTEST”,0x809900
.sect ”AICTEST”
GIE .set 0x2000
;============================================================
.C3xMMRS.ASM
A_REG .word (TA<<9)+(RA<<2)+0 ; 0x809902
B_REG .word (TB<<9)+(RB<<2)+2 ; 0x809903
C_REG .word 10000011b ; 0x809904 +/– 1.5 V
;
S0_gctrl_val .word 0x0E970300
S0_xctrl_val .word 0x00000111 ;
S0_rctrl_val .word 0x00000111 ;
;
prog_AIC push R1
push IE
ldi 0x10,IE
andn 0x30,IF
ldi @S0_xdata,R1
sti R1,@S0_xdata
idle
ldi @S0_xdata,R1
or 3,R1
sti R1,@S0_xdata
idle
sti R0,@S0_xdata
idle
andn 3,R1
sti R1,@S0_xdata
pop IE
pop R1
rets
5-4
Creating DSK Assembler Source Files
The operand field is a list of operands that follow the mnemonic field. An
operand can be a constant (see Section 5.2, page 5-8), a symbol (see Sec-
tion 5.4, page 5-11), or a combination of constants and symbols in an expres-
sion. You must separate operands with commas.
The assembler lets you specify whether to use a constant, or use a symbol as
an immediate value, a direct address or an indirect address. The following
rules apply to the operands of instructions.
5-6
Creating DSK Assembler Source Files
You can comment your source file in one of two ways. The most common way
is to place a semicolon anywhere on the line you want to comment. All text
placed after the semicolon is ignored by the DSK assembler. For example:
* Memory map register locations
SGR0 .set 0x808040 ; Serial port 0 global control register
SPCX0 .set 0x808042 ; Serial port 0 FSX/DX/CLKX control register
SPCR0 .set 0x808043 ; Serial port 0 FSR/DR/CLKR control register
DTX0 .set 0x808048 ; Serial port 0 data transmit register
DRX0 .set 0x80804c ; Serial port 0 data receive register
TGCR0 .set 0x808020 ; Timer 0 global control register
TCNT0 .set 0x808024 ; Timer 0 counter register
TPR0 .set 0x808028 ; Timer 0 period register
The second way to comment your source file is to use an asterisk in column
1 of your code.
If the asterisk is not in column 1, the assembler assumes it is part of your code
and can generate an error.
5.2 Constants
The assembler supports five types of constants:
Binary integer constants
Decimal integer constants
Hexadecimal integer constants
Floating-point constants
Character constants
The assembler maintains each constant internally as a 32-bit quantity.
Constants are not sign extended. For example, the constant 0FFh is equal to
00FF (base 16) or 255 (base 10); it does not equal –1.
Binary integers
A binary integer constant is a string of 0s and 1s followed by the suffix B (or
b). Examples of valid binary constants include:
Decimal integers
A decimal integer constant is a string of decimal digits, ranging from
–2 147 483 647 to 4 294 967 295. Examples of valid decimal constants in-
clude:
Hexadecimal integers
A hexadecimal integer constant is a string of up to eight hexadecimal digits
followed by the suffix H (or h) or preceded by the prefix 0x. Hexadecimal digits
include the decimal values 0–9 and the letters A–F or a–f. A hexadecimal
constant must begin with a decimal value (0–9). Examples of valid hexadeci-
mal constants include:
5-8
Constants
Floating-point constants
A floating-point constant is a string of decimal digits, followed by an optional
decimal point, fractional portion, and exponent portion. Examples of floating-
point numbers include:
Character constants
A character constant is a single character enclosed in single quotes. The
characters are represented as 8-bit ASCII characters. Examples of valid char-
acter constants include:
5-10
Symbols
5.4 Symbols
Symbols are used as labels, constants, and substitution symbols. A symbol
name is a string of up to eight alphanumeric characters (A–Z, a–z, 0–9, $, –,
and +); symbols cannot contain embedded blanks. The first character in a
symbol cannot be a number or special character. The symbols you define are
case-sensitive; for example, the assembler recognizes ABC, Abc, and abc as
three unique symbols.
Labels
Symbols that are used as labels become symbolic addresses that are
associated with locations in the program. A label must be unique. Note that you
should not use register names as labels.
Constants
Symbols can be set to constant values. By using constants, you can equate
meaningful names with constant values. The .set directive enables you to set
constants to symbolic names. Symbolic constants cannot be redefined. The
following example shows how these directives can be used:
.text ; initialize PC
K .set 12 ; constant definition K=12
BIN .set 01010101b ; BIN = 055h
max_buf .set K*2 ; max_buf = K*2 = 24
LDI K, R0 ; loads 12
LDI –K, R0 ; loads –12
LDI K*2, R0 ; loads 24
LDI max_buf,R0 ; loads 24
LDI !BIN, R0 ; loads 0AAh
$, the dollar sign character, represents the current value of the section pro-
gram counter (SPC).
AR0–AR7 IF PC RS
BK IOF R0–R7 SP
DP IR0 RC ST
IE IR1 RE
The expression analyzer used in the DSK assembler includes ANSI C math
library functions that aid in the generation of tables and constants. These func-
tions eliminate the tedious work of calculating tables and constants before in-
cluding them in the assembly process. The functions are shown in Table 5–2.
Note:
If you use any of these functions, a post-assembly warning is generated to
remind you that these functions are not supported by the TMS320 floating-
point code generation COFF tools. If you want to use these functions with the
COFF toolset, then extract the resulting hexadecimal values from the DSK
listing file.
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 5–2. ANSI C Math Library Functions Supported by the DSK Assembler
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Function Description
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
long abs(long); Absolute value
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
long labs(long);
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double fabs(double);
Absolute value
Floating-point absolute
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double cos(double); Cosine
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double acos(double); Arc cosine
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double cosh(double);
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double sin(double);
Hyperbolic cosine
Sine
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double asin(double); Arc sine
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double sinh(double); Hyperbolic sine
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double tan(double);
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Tangent
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double atan(double); Arc tangent
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double tanh(double); Hyperbolic tangent
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
long ceil(long);
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double floor(double);
Ceiling operator
Floor operator
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double exp(double); Natural exponent (e) raised to the power of a value
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double log(double); Natural logarithm (ln)
5-12
Expression Analyzer
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 5–2. ANSI C Math Library Functions Supported by the DSK Assembler (Continued)
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Function
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double log10(double);
Description
Logarithm (based–10)
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double pow10(double); 10 raised to the power of a value
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double sqrt(double); Square root
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double log2(double);
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
double pow(double,double);
Logarithm (based–2)
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
long br(long, long); Align the first value to the next address located by
raising the second value to the power of 2
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
long circ(long,long); Align the first value to the next address located by
raising the second value to the power of 2
You can generate a table of values using certain assembler directives. To gen-
erate a table of values use the .loop/.endloop directives and the math library
functions listed in Table 5–2. For example, to create the twiddle table for an
FFT, use the following directives:
- Subtraction = Equal to
* Multiplication == Equal to
5-14
Assembling Your Program
filename is the assembly language source file. Filenames are not case-
sensitive. If you do not specify an extension, the assembler
assumes the default extension .asm.
You can specify options and filenames in any order on the command line.
Table 5–4 lists the assembler options; the following subsections describe the
options.
Option Description
Exxx Stops assembling after xxx error messages occur (5 is the default)
In the following code example, an output section named Mysect is placed be-
ginning at address 000x80 9800. The entry (execution start) point is then de-
fined at the label START. Next, a simple code loop that increments R0 is placed
into the current section.
.start ”Mysect”,0x809800 ; Mysect begins at 0x809800
.sect ”Mysect” ; Assemble code into Mysect
.entry START ; Execution START point
START LDI 0,R0 ; Initialize R0=0
LOOP ADDI 1,R0 ; Increment R0
B LOOP ; Do it again
To place two sections of code that leave a hole of unused memory, look at the
following code. The first section, Mysect, which starts at location 0x0080 9800,
is followed by a second section, jumpback, which starts at location
0x0080 9900.
.start ”Mysect”,0x809800 ; Mysect begins at 0x809800
.sect ”Mysect” ; Assemble code into Mysect
.entry START ; Execution START point
START LDI 0,R0 ; Initialize R0=0
LOOP ADDI 1,R0 ; Increment R0
B JUMP1
;––––––––––––––––––––––––––––––
.start ”jumpback”,0x809900 ; jumpback begins at 0x809900
.sect ”jumpback” ; Assemble code into jumpback
JUMP1 ADDI 1,R0 ; Increment R0
B JUMP2
;––––––––––––––––––––––––––––––
.sect ”Mysect” ; Add more code to Mysect
JUMP2 ADDI 1,R0 ; Increment R0
B LOOP ; Finish LOOP
5-16
Placing Code Sections in Memory Locations
To simulate a linker command file, such as the one used in the TMS320 code
generation tools, you can use a single file to control the starting address of all
sections and then use the .include directive to append all assembly source
files. For example, consider the following build file where three source files are
appended to each other using a common block statement for several .start
directives.
;BUILD.ASM
;–––––––––
.start ”.text”,0x809800 ; Initialize start address for
; each section
.start ”.data”,0x809C00 ;
.start ”sect1”,0x809900 ;
.start ”sect2”,0x809A00 ;
.include ”FILE1.ASM” ; Include source files
.include ”FILE2.ASM” ;
.include ”FILE3.ASM” ;
Assembler Directives
Assembler directives supply program data and control the assembly process.
They allow you to do the following:
Assemble code and data into specified sections
Reserve space in memory for uninitialized variables
Initialize memory
Assemble conditional blocks
Topic Page
6-1
Using the DSK Assembler Directives
.sect ”section name” Assemble source code into a named (initialized) sec- 6-27
tion
.byte value1 [,..., valuen ] Initialize one or more 8-bit integers 6-16
.fill size in words Reserve size words in the current section; note that 6-29
a label points to the beginning of the reserved space
.int value1 [,..., valuen ] Initialize one or more 16-bit integers 6-16
.long value1 [, ... , valuen ] Initialize one or more 32-bit integers 6-16
.qxx value1 [,..., valuen ] Initialize a 16-bit, signed 2s-complement integer, 6-25
whose decimal point is displaced xx places from the
LSB
.space size in words Reserve size words in the current section; note that 6-29
a label points to the beginning of the reserved space
6-2
Using the DSK Assembler Directives
.string “string1 ” [,..., “stringn ”] Initialize one or more text strings 6-31
.word value1 [, ... , valuen ] Initialize one or more 32-bit integers 6-16
.loop [well-defined expression] Begin repeatable assembly of a code block; the loop 6-24
count is determined by the well-defined expression.
.align [size in bytes] Align the SPC on a boundary specified by size in bytes, 6-14
which must be a power of 2; default to byte boundary
.entry [address] Initialize the starting address of the SPC when loading 6-20
a file
.sdef value Equate a value with a local symbol multiple times 6-26
.start “section name”, address Links the named section to start assembling at the 6-30
location address.
6-4
Directives That Define Sections
The .text directive identifies portions of code in the .text section. The .text
section usually contains executable code.
Example 6–1 shows how you can use sections directives to associate code
and data with the proper sections. This is an output listing; column 1 shows,
the SPC value and column 2 shows the memory contents, if affected by the
previous line, or a comment. (Each section has a section program counter
(SPC). The .start directive for a section determines that section’s initial SPC
value. When you resume assembling into a section, its SPC resumes counting
as if there had been no intervening code.
Note:
The .text and .data directives are short hand representations of .sect state-
ments for that section name.
.text is equivalent to .sect ”.text”
.data is equivalent to .sect ”.data”
6-6
Directives That Define Sections
The .byte directive places one or more 8-bit values into consecutive words
in the current section. A byte in this case uses all 32 bits of the word placing
0s into the upper 24 bits.
The .int directive places one or more 16-bit values into consecutive words
in the current section. The upper 16 bits are not used and are filled with
0s.
The .long directive places one or more 32-bit values into consecutive by-
tes in the current section.
The .qxx directive places one or more 16-bit, signed 2s-complement val-
ues into consecutive words in the current section. Note that the decimal
point is displaced xx places from the LSB (least significant bits.)
6-8
Directives That Initialize Constants / Directives That Reference Other Files
The .string directive places 8-bit characters from one or more character
strings into the current section.
The .word directive places one or more 32-bit values into consecutive
bytes in the current section.
6-10
Directives That Align the Section Program Counter / Directives That Define Symbols at Assembly Time
The .align directive aligns the SPC at a 1-byte to 32K-byte boundary. This
ensures that the code following the directive begins on the byte value that
you specify. If the SPC is already aligned at the selected boundary, it is not
incremented.
The .entry directive identifies the starting address of the section program
counter. By default, the current address is used, or, you can specify an op-
tional address.
The .brstart directive aligns the named section to the next 2n address
boundary following the current section.
The .end directive terminates assembly. It should be the last source state-
ment of a program. This directive has the same effect as an end-of-file.
The .start. directive links the named section to start assembling at the
location address. This effectively gives the DSK assembler the func-
tionality of a linker.
6-12
Directives Reference
.if 6-23
Syntax .align
Description The .align directive aligns the current section to a 32-word boundary, filling the
hole with NOPs. If the hole is greater than 2 words, .align places a branch to
the newly-aligned address. This directive is useful for placing critical code
blocks on the boundaries that best use the cache resources of the ’C3x archi-
tecture.
6-14
Align to Address Boundary .brstart
Description The .brstart directive aligns the section name to the next 2 n address boundary
immediately following the current section. This directive aligns data buffers in
order to use the ’C3x circular and bit-reversed addressing modes. Another
method for creating a section whose start is bit-reversed, is to use the br() func-
tion within the .start directive’s address field.
Description These directives place one or more values into the current section.
The .byte directive places 8-bit values into consecutive words in the
current section. The value must be an expression that evaluates to a
number within –128 and 127. The upper 24 bits are 0.
The .int directive places 16-bit values into consecutive words in the
current section. The value must be an expression that evaluates to a
number within the range of –32768 and 32767. The upper 16 bits are
always 0.
The .long and .word directives place 32-bit values into consecutive words
in the current section. The value is an expression that the assembler eval-
uates and treats as a 32-bit signed number.
A value must be absolute. You can use as many values as fit on a single line
(80 characters). If you use a label, it points to the first word that is initialized.
6-16
Copy Source File .copy, .include
Description The .copy and .include directives tell the assembler to read source state-
ments from a different file. The assembler:
3) Resumes assembling statements in the main source file, starting with the
statement that follows the .copy or .include directive
The filename is a required parameter that names a source file. The filename
must be enclosed in double quotes and must follow operating system conven-
tions. You can specify a full pathname (for example, c:\dsktools\file1.asm). If
you do not specify a full pathname, the assembler searches for the file in the
current directory.
The .copy and .include directives can be nested within a file that is copied or
included. the assembler limits this type of nesting to eight levels; the host
operating system may set additional restrictions.
Example This example shows how the .include directive is used to tell the assembler
to read and assemble source statements from other files, then to resume
assembling into the current file.
Syntax .data
Description The .data directive tells the assembler to begin assembling source code into
data memory. The .data section normally contains tables of data or preinitial-
ized variables.
Note that the assembler assumes that .text is the default section. Therefore,
at the beginning of an assembly, the assembler assembles code into the .text
section unless you specify a section control directive.
Example This example shows how to assemble code into the .data and .text sections.
.start “.data”, 0x809900
.entry BEGIN
BEGIN ldi 0, R0 ; Initialize R0 and R1
ldi 1, R1
.data
value .int 0, 1, 2, 3, 4, 5 ; Integer values
6-18
End Assembly .end
Syntax .end
Description The .end directive is an optional directive that terminates assembly. It should
be the last source statement of a program. The assembler ignores any source
statements that follow an .end directive.
Example This example shows how the .end directive terminates assembly.
ldi 1,R1 ; Assemble this code
mpyi 5,R1 ;
.end ; Stop assembler
subi 2,R1 ; does not assemble
Description The .entry directive tells the assembler the address of the section program
counter when a file is loaded. If you do not use the value parameter, the current
program memory address, determined by the .text section, becomes the start-
ing address. If you have more than one .entry directive in your file, then the last
.entry directive encountered becomes the starting address of your code.
6-20
Initialize TMS320C3x Floating-Point Value .float, .float16, .float8, .pfloat16, .pfloat8
Description These directive convert one or more values into TMS320C3x floating-point
constants.
Note that the ’C31 expects floating-point numbers to have the 32-bit format.
Description The .ieee directive places the IEEE single-precision floating-point representa-
tion of a single floating-point constant into three bytes in the current section.
6-22
Assemble Conditional Block .if, .else, .endif
- The .if directive marks the beginning of a conditional block. The expres-
sion is a required parameter.
J If the expression evaluates to true (nonzero), the assembler as-
sembles the code that follows it (up to an .else, or an .endif).
J If the expression evaluates to false (0), the assembler assembles
code that follows an .else (if present), or an .endif.
- The .else directive identifies a block of code that the assembler assembles
when the .if expression is false (0). This directive is optional in the condi-
tional block; if an expression is false and there is no .else statement, the
assembler continues with the code that follows the .endif.
.if TRUE ;
nop ; Assembles ’nop’ since TRUE
.else ;
B $ ; Never assembles
.endif ;
6-24
Initialize 2s-Complement Integers .qxx
Description The .qxx directive generates signed, 2s-complement fractional integers and
long integers whose decimal point is displaced xx places from the LSB.
Example Here’s an example of the .qxx directive. The value of xx can be either positive
or negative.
.q0 3.1415926 ; All upper 32 bits are integers
.q1 3.1415926 ; One fractional bit (left shift 1
.q2 3.1415926 ; Two fractional bits (left shift 2)
.q16 3.1415926 ; Upper 16 are whole integers,
; lower 16 are fractional
Description The .sdef directive functions in the same manner as the .set directive;
however, .sdef can redefine the symbol name multiple times without generat-
ing an error. All instances of .sdef symbols are stripped from the symbol table
at the end of pass 1 analysis. When used with the .if directive, .sdef can condi-
tionally assemble included blocks of code. This is useful for turning on and off
included library functions.
The value must be a well-defined expression; that is, all symbols in the
expression must be previously defined in the current source module.
6-26
Assemble Into Named Section .sect
Description The .sect directive begins assembling source code into the named section.
The .sect directive defines named sections that are used like default .text and
.data sections.
The section name identifies the section. The section name is significant to 80
characters and must be enclosed in double quotes.
Description The .set directive equates a constant value to a symbol. The symbol can then
be used in place of the value in assembly source. This allows you to equate
meaningful names with constants and other values.
The value must be a well-defined expression; that is, all symbols in the
expression must be previously defined in the current source module.
6-28
Reserve Space .space, .fill
The .space directive reserves size number of words in the current section
and fills them with 0s. The SPC is incremented to point to the word follow-
ing the reserved space.
The .fill directive reserves size number of words in the current section and
fills them with value. The value must be an absolute value. The SPC is
incremented to point to the word following the reserved space.
When you use a label with the .space or .fill directive, it points to the first word
reserved.
Example This example shows how the .space and .fill directives reserve memory.
.space 12 ; Fill 12 locations with the value 0x0
.fill 3,0x5555 ; Fill three words with 0x5555
.text
.data
Description The .start directive links the section name to start at location address. This
directive effectively gives the DSK assembler the same functionality as a linker
command file when used only to create runtime executable modules. For the
specified section to have a valid starting address, the .start statement for the
section must precede the .text, .data, or .sect directive that defines the section
name. Note that by using an include file with an imbedded .if/.sdef/.endif, the
.start directive can effectively be used in place of the linker.
6-30
Initialize Text .string
Description The .string directive places one or more 8-bit character strings into consecu-
tive bytes of the current section.
The .string directive places the 8-bit values into memory in a packed form in
the order they are encountered. If a word is not filled, the remaining bits are
filled with 0s.
Example This example shows several 8-bit values placed into consecutive bytes in
memory. The label Str_3 has the value 0h, which is the location of the first ini-
tialized byte.
Str_3: .string “ABCD”
.string 51h, 52h, 53h, 54h
.string “Hoston”
.string 36+12
Syntax .text
Description The .text directive tells the assembler to begin assembling into the .text sec-
tion. The .text section usually contains executable code. The section program
counter (SPC) is set to 0, if nothing has been assembled into the .text section.
If code has already been assembled into the .text section, the SPC is restored
to its previous value in the section.
Note that the assembler assumes that .text is the default section. Therefore,
at the beginning of an assembly, the assembler assembles code into the .text
section unless you specify one of the other sections directives (.data, .entry,
or .sect).
Example This example shows the assembly of code into the .data and .text sections.
.start “.text”, 0x809800
.entry START
START ldi 0, R0 ; Initialize R0 and R1
ldi 1, R1
.text
value .int 0, 1, 2, 3, 4, 5 ; integer values
6-32
Chapter 7
This chapter tells you how to invoke the DSK debugger and use its function
keys and commands.
Topic Page
7-1
Invoking the Debugger
dsk3d [options]
Table 7–1 lists the debugger options; the following subsections describe some
of the more commonly used options.
TEST Searches automatically through LPT1, LPT2, and LPT3 for the
presence of a DSK
T = xx Adds extra xx I/O bus cycles to each transfer for long or noisy
cables
You can display the contents of Table 7–1 on your screen by using the ? or Help
option. For example, enter:
dsk3d ?
7-2
Invoking the Debugger
The LPT option selects a parallel printer port from the host to communicate
with the DSK.
Note:
Some EISA machines and IBM PS/2s use a different naming convention for
the LPTx.
AT Convention EISA and PS/2 I/O Address
LPT1 LPT2 ox378
LPT2 LPT3 0x278
LPT3 LPT1 0x3BC
The port option selects the parallel printer port at the given address. For
example:
port = 0x378
Note:
Use this option with extreme care since any base address can be used.
Use the test option to systematically search for a parallel port that has a DSK
connected. The search loops through LPT1, LPT2, and LPT3.
Note:
If you have a printer port or other peripheral connected to your PC, turn it off
before using the test option.
DISASSEMBLY window
The DISASSEMBLY window shows the reverse assembly of memory con-
tents. As shown in Figure 7–1, this window displays several lines of code.
Each line shows the instruction address, instruction opcode, label, and instruc-
tion mnemonic. The highlighted line corresponds to the next instruction to be
executed.
DISASSEMBLY
809c03 50700080 start LDIU 00080h,DP
809c04 08349c2c LDI @09c2cH,SP
809c05 07608000 LDF 0.000000e+00,R0
809c06 c610c1c0 LDI *AR0,R0 || LDI *AR
809c07 c610c1c0 LDI *AR0,R0 || LDI *AR
809c08 08600100 LDI 256,R0
809c09 09a09c00 LSH @09c00H,R0
809c0a 61809c0e BRD jump
809c0b 07618000 LDF 0.000000e+00,R1
809c0c 07628000 LDF 0.000000e+00,R2
809c0d 07630000 LDF 1.000000e+00,R3
809c0e 07640000 jump LDF 1.000000e+00,R4
809c0f 087b0003 loop LDI 3,RC
809c10 64809c1a RPTB block
809c11 02640001 ADDI 1,R4
7-4
Understanding the Debugger Windows
Register contents
MEMORY window
The MEMORY window shows the contents of a range of memory as shown in
Figure 7–3. The MEMORY window has two parts:
For example, the MEMORY window below has four columns of data, so each
new address is incremented by 4. Although the window shows four columns
of data, there is still only one column of addresses; address 0x0080 9800 con-
tains 0x0000 0007, address 0x0080 9801 contains 0xFFFF FFFC, address
0x0080 9804 (the first value in the second row) contains 0x0080 982C, ad-
dress 0x0080 9805 contains 0x0080 9839, etc.
MEMORY
To modify the contents of the MEMORY window, press ALT M to activate the
window and then type over the data. To select a cell, you can use the following
keys:
7-6
Understanding the Debugger Windows
COMMAND window
The COMMAND window provides an area for entering commands, echoing
commands, and displaying command output errors and messages. The
COMMAND window has two parts:
- Command line. This is the area where you enter commands. When you
want to enter a command, just type — no matter which window is active.
- Display area. This area echoes the commands that you enter, shows any
output from your commands, and displays debugger error messages.
Figure 7–4 shows the window command line and display area.
Command line
J
You can use the ↑ and ↓ keys to select a previously entered command from
the buffer (a > is used to indicate the buffer). The editing command keys are
shown in Table 7–2.
KEYBOARD COMMANDS
F1 Help Screen
F2 40-bit hex display
F3 FLOAT display
F4 Source/DASM debug toggle
F5 Run
F6 Display breakpoints
F7 Clear all breakpoints
F8 Singlestep
F9 Toggle DASM window size
F10 Step over function
H to enter a second help level. The second help level is more hardware-
oriented and deals less with debugger-specific commands.
7-8
Using Software Breakpoints
While debugging, you may want to halt execution temporarily so that you can
examine the contents of selected variables, registers, and memory locations
before continuing with program execution. You can do this by setting software
breakpoints in the assembly language code. A software breakpoint halts any
program execution, whether you’re running or single-stepping through code.
When you set a software breakpoint, the debugger highlights the breakpointed
line in a bolder or brighter font. The highlighted statement appears in the DIS-
ASSEMBLY window.
sb addr If you know the address where you’d like to set a software breakpoint, you can
use the SB command. This command is useful because it doesn’t require you
to search through code to find the desired line. When you enter the SB com-
mand, you enter an absolute address (addr). (Once you have entered the ad-
dress, you are asked to choose the line number you want the breakpoint set
on.) Note that you cannot set multiple breakpoints at the same statement.
cb addr If you’d like to clear a breakpoint, you can use the CB command. You can use
the CB command to clear a specific address by entering an absolute address
(addr) after the command. You can clear all breakpoints by entering the CB
command without an address.
db Sometimes, you may need to know where software breakpoints are set. The
DB command provides an easy way to get a complete listing of all the software
breakpoints that are currently set in your program.
Execute n instructions XN n
7-10
Debugger Commands
Fill leng locations of memory starting at address addr MM addr leng val
with value val. If val is expressed in a floating-point
format (with a decimal point), it will be converted into
a TMS320 floating-point format.
Enter the DOS shell and optionally execute the ex- DOS (expression to Run)
pression. Enter EXIT to return to debugger
Enter the DOS shell and execute the editor to edit EDIT filename
filename. (If no filename is given, the name of the
presently loaded file is used).
Enter the DOS shell and execute the DSK assembler dsk3a filename.asm
to assemble file
7-12
Quick Reference Guide
F4 Run to cursor
F5 Run
F6 Display breakpoints
F9 Grow window
7-14
Appendix
AppendixAA
This appendix contains the source code for the TMS320C3x DSK communica-
tions kernel.
A-1
Communications Kernel Source Code
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
; TMS320C3x DSK COMMUNICATIONS AND DEBUG MONITOR KERNAL ;
; Texas Instruments Incorporated ;
; (C) 1995,1996 ;
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
.start ”vectors”,0x809FC1
.start ”kernel” ,vectors–0xAB ; Use size report from DSK3A
.start ”sstack” ,0x809F00 ; output to pack to end of RAM
.entry START
;=====================================================================;
; COMMUNICATION MONITOR START ;
; ;
; STACK SPACE ;
; ––––––––––– ;
; A section of unoccupied free memory of STACKSIZE size words just ;
; below the kernel is used on startup for initialization and stack ;
; space. If more (or less) stack space is required, a new stack ;
; pointer value can be initialized within the users applications code ;
; to any location, or by re–assembling this code with a new STACKSIZE ;
; ;
; When initialization is complete, the startup stub can be safely ;
; overwritten since it is no longer needed. In this case the startup ;
; stub is placed after the stack. Another ’safe’ location would be ;
; a section of memory which is used for I/O or uninitialized data. ;
; ;
; This section of code also initializes the timers which are used by ;
; the PAL to create the PWM signal which drives the LED. The rate ;
; at which the LED changes color is F0–F1 where F0 and F0 are the two ;
; timer output frequencies. (See the Users Guide ;
;=====================================================================;
.sect ”sstack”
stack: .word stack–1 ; start of kernel stack
MMRBASE .word 0x00808000 ;
PRD0 .word 0x0000A000 ;
PRD1 .word 0x0000A060 ;
TSTART .word 0x000003C3 ;
START ldp @START ; Set up stack and other params
ldi @stack,SP ;
;=======================
ldi @MMRBASE,AR0 ; Init timers for slow PWM modulation
ldi 3,R0 ; HALT timers
sti R0,*+AR0(0x20) ;
sti R0,*+AR0(0x30) ;
sti R0,*+AR0(0x24) ; Init count registers
sti R0,*+AR0(0x34) ;
ldi @PRD0,R0 ; Init periods
sti R0,*+AR0(0x28) ;
ldi @PRD1,R0 ;
sti R0,*+AR0(0x38) ;
ldi @TSTART,R0 ; Start timers
sti R0,*+AR0(0x20) ;
sti R0,*+AR0(0x30) ;
b spin0 ;
A-2
Communications Kernel Source Code
;========================================================================;
; DEBUGGER COMMANDS ;
; The debugger commands are assembled into the lowest available kernel ;
; memory. If an application were to overgow this section the debugger ;
; functions would be corrupted, but the application would continue to ;
; run so long as the debugger functions were not used. ;
;========================================================================;
; XSTEP/XRUNF ;
; ;
; These functions restore the CPU registers from the context save area ;
; before returning to the code pointed to by the program counter value. ;
; The only difference is that XSTEP purposely sets the interrupt flag ;
; used for single stepping before returning to the users code. ;
; ;
; SINGLE STEPPING ;
; The tail end of this function is written such that a pending ;
; interrupt will not be serviced until one opcode has been fetched from ;
; the return address and executed (there may be other dummy fetches). ;
; This ’pending’ interrupt then causes the processor to return back to ;
; the context save routine, effectively singlestepping the CPU. ;
; ;
;========================================================================;
S0_xdata .set 0x808048 ; SP 0 Data transmit
S0_rdata .set 0x80804C ; SP 0 Data receive
.sect ”kernel”
.word 0x00320C31 ; Prepend a few easily recognizable markers
.word 0x00320C31 ;
XSTEP or 0x40,IF ; set XINT1 (safe INT for C31/C32 debug!)
XRUNF or 0xC4,IE ; set EXINT1 (safe INT for C31/C32 debug!)
;–––––––––––––––––––––––
sti IE,@_freerun ; Freerun !=0 indicates DSK is not halted
;–––––––––––––––––––––––
ldi @CPUCTXT,AR0 ; Use parallel opcodes for squeeze
ldi AR0,AR1 ;
addi 1,AR1 ;
ldi 2,IR0 ;
;–––––––––––––––––––––––
ldi @S0_rdata,R0 ; Clear under/overrun conditions before exit
ldi 0,R0 ; 0 ensures low bits during SP recovery
sti R0,@S0_xdata ; XSR resends – should all be zero
ldf *AR0++(IR0),R0 ; load floats (exponents)
|| ldf *AR1++(IR0),R1 ;
ldf *AR0++(IR0),R2 ;
|| ldf *AR1++(IR0),R3 ;
ldf *AR0++(IR0),R4 ;
|| ldf *AR1++(IR0),R5 ;
ldf *AR0++(IR0),R6 ;
|| ldf *AR1++(IR0),R7 ;
;– – – – – – – – – – – –
ldi *AR0++(IR0),R0 ; load longs (mantissa)
|| ldi *AR1++(IR0),R1 ;
ldi *AR0++(IR0),R2 ;
|| ldi *AR1++(IR0),R3 ;
ldi *AR0++(IR0),R4 ;
|| ldi *AR1++(IR0),R5 ;
ldi *AR0++(IR0),R6 ;
|| ldi *AR1++(IR0),R7 ;
;– – – – – – – – – – – –
ldi @_AR0,AR0 ; load ARx
ldi @_AR1,AR1 ;
ldi @_AR2,AR2 ;
ldi @_AR3,AR3 ;
ldi @_AR4,AR4 ;
ldi @_AR5,AR5 ;
ldi @_AR6,AR6 ;
ldi @_AR7,AR7 ;
ldi @_IR0,IR0 ;
ldi @_IR1,IR1 ;
; or @_IF,IF ; CPU interrupt flags
ldi @_IOF,IOF ; IO flags
ldi @_RS,RS ; Repeat start
ldi @_RE,RE ; Repeat end
ldi @_RC,RC ; Repeat counter
ldi @_BK,BK ; Block size
ldi @_SP,SP ; get user SP
;– – – – – – – – – – – –
ldi @_PC,R5 ; return to PC from TOS return
andn 0x4,IF ; Clear/Poll INT2 before SSTEP or RUNF
tstb 4,IF ;
bnz $–3 ;
ldiu @_ST,ST ; restore Status
or @_IE,IE
BUD R5 ;
or 2000h,ST ; turn on INT’s
ldiu @_R5,R5 ;
ldiu @_DP,DP ; restore DP
;========================================================================;
; XHALT ;
; When called this function restores the temporary use registers used ;
; for quick returns from the XWRITE/XREAD before falling into a full ;
; context save, followed by waiting for a new command. ;
;========================================================================;
XHALT pop AR1 ; restore original registers before save
pop AR0 ;
pop IR1 ;
pop R0 ;
pop DP ;
pop ST ; User PC now at TOS
A-4
Communications Kernel Source Code
;========================================================================;
; SSTEP ;
; This section of code is executed after the pending interrupt, which ;
; was set in XSTEP, has feteched the ISR vector and begun execution. ;
; This code performs a full CPU context save before going to the spin ;
; loop to await further commands. ;
;========================================================================;
SSTEP push DP ; temp storage of user DP
ldp @_ST ; DP for kernal
sti ST,@_ST ; store ST
sti IR0,@_IR0 ; IR0 used as temp, later for indexed store
pop IR0 ; save user DP
sti IR0,@_DP ;
pop IR0 ; save user PC
sti IR0,@_PC ;
sti SP,@_SP ; save user SP
sti BK,@_BK ; Block size
sti IE,@_IE ; Internal int enable
sti IF,@_IF ; CPU interrupt flags
sti IOF,@_IOF ; IO flags
sti RS,@_RS ; Repeat start
sti RE,@_RE ; Repeat end
sti RC,@_RC ; Repeat counter
; sti IR0,@_IR0 ; Keep everything <– IR0 Saved previously
sti IR1,@_IR1 ;
;– – – – – – – – – – – –
sti AR0,@_AR0 ; Use parallel opcodes for squeeze
sti AR1,@_AR1 ;
ldi @CPUCTXT,AR0 ;
ldi AR0,AR1 ;
addi 1,AR1 ;
ldi 2,IR0 ;
;– – – – – – – – – – – –
stf R0,*AR0++(IR0) ; Store floats
|| stf R1,*AR1++(IR0) ;
stf R2,*AR0++(IR0) ;
|| stf R3,*AR1++(IR0) ;
stf R4,*AR0++(IR0) ;
|| stf R5,*AR1++(IR0) ;
stf R6,*AR0++(IR0) ;
|| stf R7,*AR1++(IR0) ;
;– – – – – – – – – – – –
sti R0,*AR0++(IR0) ; Store longs
|| sti R1,*AR1++(IR0) ;
sti R2,*AR0++(IR0) ;
|| sti R3,*AR1++(IR0) ;
sti R4,*AR0++(IR0) ;
|| sti R5,*AR1++(IR0) ;
sti R6,*AR0++(IR0) ;
|| sti R7,*AR1++(IR0) ;
;– – – – – – – – – – – –
sti AR2,@_AR2 ; AR0 & AR1 Already saved
sti AR3,@_AR3 ;
sti AR4,@_AR4 ;
sti AR5,@_AR5 ;
sti AR6,@_AR6 ;
sti AR7,@_AR7 ;
;–––––––––––––––––––––––––––––––
ldi 0, R0 ; Freerun = 0 indicates HALT (spin0)
sti R0,@_FREERUN ;
TRAP_AK call W_HOST ; Send ACKNOWLEDGE (zero) to host
; b spin0 ; <– Branch is removed (spin0 is inline)
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
; The spin0 code loop is used by the kernel as a known program loop ;
; when a process is halted. While in the spin loop, commands can be ;
; processed. This code loop is primarily used while debugging or ;
; during startup as a known useable code loop. ;
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
spin0 or 4,IE ; Enable DSK31 HPI interrupt
and 4,IE ; Shut down all interrupts except host
b spin0 ;
;–––––––––––––––––––––––––––––––
S0xdata .word 0
GIE .set 0x2000
A-6
Communications Kernel Source Code
;=====================================================================;
; REGISTER CONTEXT STORAGE ;
; This block of memory holds the register values when a process is ;
; stopped. Essentially the registers displayed in the debugger are ;
; the contents of this memory block. ;
;=====================================================================;
context ;
_F0 .word 0 ; R0
_F1 .word 0 ; R1
_F2 .word 0 ; R2
_F3 .word 0 ; R3
_F4 .word 0 ; R4
_F5 .word 0 ; R5
_F6 .word 0 ; R6
_F7 .word 0 ; R7
_R0 .word 0 ; F0
_R1 .word 0 ; F1
_R2 .word 0 ; F2
_R3 .word 0 ; F3
_R4 .word 0 ; F4
_R5 .word 0 ; F5
_R6 .word 0 ; F6
_R7 .word 0 ; F7
_AR0 .word 0 ; AR0
_AR1 .word 0 ; AR1
_AR2 .word 0 ; AR2
_AR3 .word 0 ; AR3
_AR4 .word 0 ; AR4
_AR5 .word 0 ; AR5
_AR6 .word 0 ; AR6
_AR7 .word 0 ; AR7
_DP .word 0 ; Data page
_IR0 .word 0 ; Index register 0
_IR1 .word 0 ; Index register 1
_BK .word 0 ; Block size
_SP .word stack–1 ; Stack pointer (initial DSK3D value)
_ST .word 0 ; Status
_IE .word 0 ; Internal int enable
_IF .word 0 ; CPU interrupt flags
_IOF .word 0 ; I/O flags
_RS .word 0 ; Repeat start
_RE .word 0 ; Repeat end
_RC .word 0 ; Repeat counter
_PC .word 0 ; program counter
_FREERUN .word 0 ; 1 = DSK is free running, 0 = DSK is HALT’ed
CPUCTXT .word context ;
;********************************************************************;
; KERNEL COMMANDS ;
; ––––––––––––––– ;
; These commands are the primary functions required by the kernel ;
; to perform host based communications. They have been packed into ;
; the avalable memory in such a way as to minimize the kernels size. ;
; The non–debugger functions have also been placed after the debugger;
; commands making it easier to simply allow the application to ;
; ’overwrite’ the debugger commands. ;
;********************************************************************;
;====================================================================;
; INTx is the starting point for all host generated commands. ;
; A host generated command is received when INT2 goes active (driven ;
; low) indicating HPSTB has gone low and that the host would like to ;
; transfer a piece of data or command. ;
;====================================================================;
INTx ; maxspeed
push ST ; Push ISR variables
push DP ;
push R0 ; NOTE: A HALT command pops these
push IR1 ; values followed by a full save
push AR0 ;
push AR1 ;
ldp @JUMP ; Get address of command from JUMP table
ldi @S0_xdata,R0 ; Put a zero in the DXR making startup
sti R0,@S0xdata ; from a stalled port safe for the AIC
ldi 0,R0 ; which cannot accept ’garbage’ which
sti R0,@S0_xdata ; would reprogram it.
tstb 4,IF ; Get here by driving INT2 low
bz SR2 ; Make sure INT2 is active
call R_HOST ; R0==command
ldi R0,AR1 ;
addi @JUMP,AR1 ;
ldi *AR1,AR1 ;
b AR1 ; execute command
;********************************************************************
; COMN is used by both the XWRIT and XREAD functions to receive the
; block transfer length, address and address increment value.
;********************************************************************
COMN call R_HOST ;
ldi R0,AR1 ; data packet length
call R_HOST ;
ldi R0,AR0 ; source address
call R_HOST ;
ldi R0,IR1 ; source index
subi 1,AR1 ;
rets ;
A-8
Communications Kernel Source Code
;====================================================================;
; The XCTXT command returns the address of the context save area to ;
; the host. Subsequently, the host can use this address to ’get’ ;
; and put the CPU registers to modify the exectution of the processor;
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––;
XCTXT ldi @CPUCTXT,R0 ; Transmit location of context to CPU
call W_HOST ;
; b SR2 ;
;====================================================================;
; SR2 is the short ’common’ return sequence used by most commands. ;
; when executed, the return will send the CPU back to the users code ;
;====================================================================;
SR2 ldi 07F00h,AR0 ; Dummy non–HPI read releases READY
ldi *AR0,AR0 ;
pop AR1 ; restore ISR variables
pop AR0 ;
pop IR1 ;
pop R0 ;
pop DP ;
; andn 0x4,IF ;
; or 4,IE ;
pop ST ;
reti ; return to original code
;====================================================================;
; TMS320C31 SECONDARY VECTOR TABLE ;
; –––––––––––––––––––––––––––––––– ;
; When the TMS320C31 receives an interrupt it first fetches an ;
; address from the primary vector table (located in the bootloader ;
; ROM). This 32 bit value is then used as an address where the ;
; new execution begins. ;
; ;
; Since it is impossible to relocate the vector table, or modify ;
; the contents of the bootloader ROM, a ’secondary’ or ’branch’ ;
; vector table is used to direct execution to the correct routines. ;
; In this case the C31’s primary vector table has been filled with ;
; interrupt routine addresses which point to the upper memory of ;
; internal RAM beginning at 0x809FC0. Since these locations are ;
; were execution actually begins, and can be modified, a branch ;
; opcode can be used to direct execution to the desired location. ;
;====================================================================;
.sect ”vectors”
INT0 b $ ; 0x809FC1 0x001
INT1 b $ ; 0x809FC2 0x002
INT2 b INTx ; 0x809FC3 0x004 <– HPI
INT3 b $ ; 0x809FC4 0x008
XINT0 b $ ; 0x809FC5 0x010
RINT0 b $ ; 0x809FC6 0x020
XINT1 b SSTEP ; 0x809FC7 0x040 <– SSTEP
RINT1 b SSTEP; TRAPFIX ; 0x809FC8 0x080 <– ETRAP 0x74000008
TINT0 b $ ; 0x809FC9 0x100
TINT1 b $ ; 0x809FCA 0x200
DINT b $ ; 0x809FCB 0x400
;====================================================================;
; HOST HPI communications routines packed into himem ;
; ;
; NOTE: These routines can be called from a high level langauge ;
; compiler using the C31s TRAP commands, by directly linking their ;
; resolved addresses or by using the jump table. ;
;====================================================================;
; W_HOST performs an interlocked Host Port write of the contents ;
; of R0 to the host using the HPSTB/HPACK protocol. When called the ;
; host PC should be waiting for this function to send data. ;
;====================================================================;
W_HOST push AR0 ; Used for HPI address
push AR1 ; Used for loop counter
push ST ; Keep flags
push DP ; Might not be on same page
ldp WSCOUNT ;
ldi 0xF000,AR0 ; HPI address sign extends to 0xFFF000
ldi @WSCOUNT,AR1 ;
WH sti R0,*AR0++(16) ; Store lsbs to HPI
lsh @WSHIFT,R0 ; shift to next lsbs
db AR1,WH ; loop until done
pop DP ;
b COMNHST ;
;====================================================================;
; R_HOST performs an interlocked Host Port read from the printer ;
; port interface and places the result into R0. ;
;====================================================================;
R_HOST push AR0 ; HPI Address
push AR1 ; loop counter
push ST ;
push R1 ; temp register
ldi 0xF000,AR0 ; HPI address sign extends to 0xFFF000
ldi 3,AR1 ; bytes–1 to receive
RH lsh –8,R0 ; shift result right one byte
ldi *AR0++,R1 ; Load byte
lsh 24,R1 ; shift to upper byte
or R1,R0 ; or w/result
db AR1,RH ; loop until done
pop R1 ; restore
;;;; b COMNHST ; <– Branch can be saved
COMNHST pop ST ; Next 4 opcodes common to W_HOST/R_HOST
pop AR1 ;
pop AR0 ;
rets ;
;====================================================================;
; XWRIT is a host port command designed to transfer a block of ;
; data from the host to the C31’s memory. ;
;====================================================================;
XWRIT call COMN ;
XW1 call R_HOST ;
sti R0,*AR0++(IR1) ;
db AR1,XW1 ;
b SR2 ;
A-10
Communications Kernel Source Code
;====================================================================;
; XREAD is a host port command designed to transfer a block of ;
; data from C31 memory to the host. ;
;====================================================================;
XREAD call COMN ;
XR1 ldi *AR0++(IR1),R0 ;
call W_HOST ;
db AR1,XR1 ;
b SR2 ;
;====================================================================;
; There are a few leftover traps that can be used by appliactions ;
; The number of TRAPs coincides with the amount of available unused ;
; memory before the JUMP table is encountered and was adjusted by ;
; hand by looking at the assembler listing ;
;====================================================================;
TRAP00 b $ ; Leftover TRAPs which can be
TRAP01 b $ ; used by applictions
;====================================================================;
; A JUMP table can also be used to access the DSK3 routines from ;
; other applications that require host communications. In this case ;
; the contents of the loaction specified can be used in a register ;
; call or branch. ;
;====================================================================;
; .start ”JMPTBL”,0x809FF4
; .sect ”JMPTBL”
JUMP .word JUMP ;0x809FF4 Jump table base address
.word XWRIT ;1 ;0x809FF5 for DSK3 routines
.word XREAD ;2 ;0x809FF6
.word XCTXT ;3 ;0x809FF7
.word XRUNF ;4 ;0x809FF8
.word XSTEP ;5 ;0x809FF9
.word XHALT ;6 ;0x809FFA
.word W_HOST ;7 ;0x809FFB
.word R_HOST ;8 ;0x809FFC
.word spin0 ;10 ;0x809FFD Use for spare command
;====================================================================;
; The last two locations of internal memory hold the two parameters ;
; which define the printer ports bus return width. Depending on the ;
; values, either 8 bit bi–directional or 4 bit nibble returns can ;
; be implimented. These values control the loop count and shift ;
; value needed to place the correct bits on the proper return buffer ;
; inputs. ;
; ;
; DO NOT OVERWITE THESE VALUES unless you are performing buswidth ;
; verification or setup. For more details, see the communications ;
; initialization routines within the host side code. ;
;====================================================================;
WSCOUNT .word 7 ;0x809FFE These locations hold the W_HOST
WSHIFT .word –4 ;0x809FFF buswidth parameters (Nibble/Byte)
.end
Figure B–1 shows the dimensions of the DSK circuit board, and the rest of the
appendix contains a brief description of the hardware in the TMS320C3x DSP
Starter Kit, the schematic diagrams and design notes for host interface control.
B-1
B-2
5.000
TLC32040CFN
3.3500
3.2000 3.2000
2.5820
2.1250
1.6560 3.5000
1.0750
0.7300
0.0500
0.0000 0.0000
–0.1500
Hardware Component Overview
Jumper block header — An 11-pin jumper block connects the ’C31 serial
port to the TLC32040 AIC. Removal of the jumpers disconnects the AIC
from the ’C31 serial port, so that a daughtercard can use the serial port
signals.
Oscillator — The on-board 50Mhz oscillator drives the ’C31 clock input.
The ’C31 internal clock value is divided by 1 (same frequency).
RCA jacks — The RCA jacks supply analog input or output and are routed
to the I/O pins of the AIC.
TLC32040 AIC — The analog interface circuit provides the ’C31 access
to the analog world. The AIC samples analog data and converts it into a
digital stream for ’C31 analysis. The ’C31 operates on this digital data and
returns the “transformed” digital data to the AIC for conversion into an ana-
log signal.
Voltage Regulators - The DSK uses a 7–12 Vdc or 6–9 Vac wall mount
power supply. The 7–12 Vdc supply voltage is full-wave rectified and then
regulated up to 5 volts by the LM7805. It is also converted to –5 volts by
the capacitive switching circuit LT1054, and then regulated by the
LM7905. The 6–9 Vac supply is full-wave rectified and then regulated by
the LM7805 and LM7905 to +5V and –5V, respectively. The +5V and –5V
supplies are used to power all of the DSK on-board circuitry. The
TLC32040 AIC requires a negative poser supply of –5 volts.
XDS Emulator Port — An 11-pin header that connects the XDS510 emu-
lator to the ’C31. The emulator allows you to upgrade to the full-featured
XDS debugger to debug your application code while using the DSK as the
XDS target board.
B.2 Schematics
The schematic diagrams included here show all of the internal and external
connections in the DSK circuitry.
B-4
Schematics
B-6
Schematics
B-8
Schematics
B-10
Host Interface Control Design Notes
B-12
Host Interface Control Design Notes
Note:
The simulation vectors are omitted for clarity and brevity.
Glossary
A
absolute address: An address that is permanently assigned to a memory
location.
autoexec.bat: A batch file that contains DOS commands for initializing your
PC.
B
batch file: A file that contains DOS commands for the PC to execute.
block: A set of declarations and statements that are grouped together with
braces.
C-1
Glossary
C
code-display windows: Windows that show code, text files, or code-
specific information.
command line: The portion of the COMMAND window where you can enter
commands.
common object file format (COFF): An object file that promotes modular
programming by supporting the concept of sections.
D
debugger: A windows-oriented software interface that helps you to debug
DSK programs running on a DSK board.
C-2
Glossary
E
EGA: Enhanced Graphics Adaptor. An industry standard for video cards.
external symbol: A symbol that is used in the current program module but
defined in a different program module.
F
file header: A portion of a COFF object file that contains general informa-
tion about the object file (such as the number of section headers, the type
of system the object file can be downloaded to, the number of symbols
in the symbol table, and the symbol table’s starting address).
G
global: A kind of symbol that is either: 1) defined in the current module and
accessed in another or 2) accessed in the current module but defined in
another.
I
input section: A section from an object file that will be linked into an
executable module.
L
label: A symbol that begins in column 1 of a source statement and corre-
sponds to the address of that statement.
listing file: An output file created by the assembler that lists source state-
ments, their line numbers, and any unresolved symbols or opcodes.
Glossary C-3
Glossary
M
member: An element or variable of a structure, union, or enumeration.
memory map: A map of target system memory space that is partitioned into
functional blocks.
N
named section: 1) An initialized section that is defined with a .sect directive,
or 2) an uninitialized section that is defined with a .usect directive.
O
object file: A file that has been assembled and contains machine-language
object code.
P
PC: Personal computer or program counter, depending on the context and
how it’s used. In this book, installation instructions or in information relat-
ing to hardware and boards, PC means Personal Computer (as in IBM
PC). In general debugger and program-related information, PC means
Program Counter, which is the register that identifies the current state-
ment in your program.
parallel port: The parallel printer port interface is primarily used for connect-
ing printers to the computer system, although the parallel port can also
be used for other peripherals. In this case, the ’C3x DSK is connected
to the parallel printer port.
C-4
Glossary
R
raw data: Executable code or initialized data in an output section.
S
section: A relocatable block of code or data that ultimately occupies contig-
uous space in the memory map.
serial port: The serial port that the DSK uses for communicating with the
analog interface circuit (AIC). The port address is selected, based on
which communcation port the AIC is attached to.
single-step: A form of program execution that allows you to see the effects
of each statement. The program is executed statement by statement; the
debugger pauses after each statement to update the data-display
windows.
source file: A file that contains C code or assembly language code that will
be assembled to form a temporary object file.
V
VGA: Video Graphics Array. An industry standard for video cards.
W
window: A defined rectangular area of virtual space on the display.
Glossary C-5
Index
Index
Index-1
Index
C D
.data directive 6-5, 6-18
c or com debugger option 7-3
data packets 4-8
’C31 timer structure 4-8
initializing 4-14 to 4-15
debugger
example code 4-15
definition C-2
maximum timer period register value 4-15
description of 3-2 to 3-3
minimum timer period register value 4-14
display, basic 3-3
cable requirements 2-3 key features 3-3
character, constants 5-9 options 7-2
?, 7-2
circuit diagram 4-3
c or com 7-3
clearing software breakpoints 7-9 h 7-2
code-display windows, definition C-2 debugging functions
COFF, definition C-2 communications kernel 4-10 to 4-13
single-step flow diagram 4-12
command line, definition C-2 single-step pipeline flow 4-13
comment, definition C-2 decimal integer constants 5-8
comments 5-7 to 5-18 developing code 3-4
in assembly language source code 5-7 directives
communications kernel 4-8 to 4-13 assembler
commands 4-9 binary integers 5-8
data packets 4-8 character constants 5-9
structure 4-8 hexadecimal integers 5-8
debugging functions 4-10 to 4-13 definition C-2
flow diagram 4-12 disassembly, definition C-2
pipeline flow 4-13 display directory, function key method 7-14
source code A-1 display requirements 2-2
conditional assembly 6-10 driver.cpp 4-23
conditional block, definition C-1 DSK assembler, using 5-1 to 5-18
config.sys file 2-5 DSK host software 4-23
DSK overview 1-3
connecting the DSK 2-4
dsk3a.exe command 2-3
constant, definition C-2
dsk3d.exe command 2-3
constants 5-8, 5-11
dska command 3-5, 5-15
assembly-time 5-8
dskd command 3-5, 7-2
binary integers 5-8
character 5-9 DSP, defined C-2
decimal integers 5-8
hexadecimal integers 5-8
symbols as 5-8
E
contacting Texas Instruments, vii EGA, definition C-3
.copy directive 6-9, 6-17 .else directive 6-10, 6-23
cursors .end directive 6-12, 6-19
command-line cursor, definition C-2 .endif directive 6-10, 6-23
definition C-2 .endloop directive 6-10, 6-24
Index-2
Index
G L
GET DEBUG_CTXT 4-26 –l option 3-5
getmem 4-24 label, definition C-3
getting started 3-5 labels 5-3 to 5-18
global symbol, definition C-3 case sensitivity 5-3
in assembly language source 5-2
syntax 5-2
H LF_Cmd 4-29
listing file, definition C-3
h debugger option 7-2
listing software breakpoints 7-9
HALT_CPU 4-25
.long directive 6-8, 6-16
hardware, checklist 2-2
.loop directive 6-10, 6-24
hardware component overview B-3, B-11
LSB, defined C-3
hardware interface 4-2
AIC 4-6 LSByte, defined C-3
host 4-2 to 4-3
host communications 4-4 to 4-5
memory map 4-7 M
TLC32040, 4-6
member, definition C-4
hardware overview 4-1
memory map 4-7
hardware requirements, optional 2-3 definition C-4
hexadecimal integers 5-8 memory requirements 2-2
host requirements 2-2 miscellaneous files 2-3
host software 4-23 mnemonic, definition C-4
mnemonic field 5-4
I syntax 5-2
MSB 5-3
.ieee directive 6-8, 6-22 definition C-4
.if directive 6-10, 6-23 MSb, definition C-4
Index-3
Index
reset 4-27
N RUN_CPU 4-25
named section, definition C-4
S
O .sdef directive 6-11, 6-26
object file, definition C-4 secondary communications 4-18 to 4-22
control register bit fields 4-19
object.cpp 4-23
data format 4-18
opcodes, defining 5-4 to 5-18
.sect directive 6-5, 6-27
operand, definition C-4
section, definition C-5
operands 5-5 section program counter. See SPC
label 5-11
serial port
prefixes 5-5
definition C-5
operating system 2-3 identifying 7-3
options .set directive 6-11, 6-28
assembler 5-15
single-step, definition C-5
debugger 7-2
definition C-4 singlestep, function key method 7-13, 7-14
overview, DSK system 1-3 single-step flow diagram 4-12
single-step pipeline flow 4-13
software breakpoints 7-9
P BA command 7-9
BD command 7-9
PATH statement 2-6 BL command 7-9
PC, definition C-4 clearing 7-9
.pfloat16 directive 6-21 listing 7-9
.pfloat8 directive 6-8, 6-21 setting 7-9
power requirements 2-2 software checklist 2-3
predefined symbols 5-11 source
primary communications 4-17 to 4-18 listings 5-2
statement
print screen, function key method 7-14
format 5-2
program comment field 5-7
assembling 5-15 label field 5-3
entry point, definition C-3 mnemonic field 5-4
putmem 4-24 operand field 5-5
number (source listing), 5-2
source file, definition C-5
Q source files 5-2 to 5-7
commenting 5-7 to 5-18
.qxx directive 6-8, 6-25
labeling 5-3 to 5-18
opcodes 5-4 to 5-18
R .space directive 6-9, 6-29
SPC
raw data, definition C-5 assigning a label to 5-3
recv_long 4-28 value, associated with labels 5-3
recv_long_byte 4-27 SSTEP_CPU 4-25
required files 2-3 .start directive 6-12, 6-30
Index-4
Index
W
T
windows, definition C-5
target.cpp 4-23 word, definition C-5
.text directive 6-5, 6-32 .word directive 6-9, 6-16
timer period register value
maximum 4-15
minimum 4-14
X
TLC32040, hardware interface 4-6 xmit_long 4-28
Index-5