Summary: The intent of this laboratory module is to familiarize you with the basics of the debugging environment and assembly code for the TI-54x DSP. In this module, you will be working with code that filters signals using FIR (finite impulse response) filters.
0000h and 005Fh. Special
opcodes are provided to speed access to these memory-mapped
registers.
A and
B) and a 16-bit temporary storage register
(T).
PC)
register as well as other necessary registers for repeating
code. For data memory manipulation, the data address
generation logic (DAGEN) is used and
maintains the necessary registers including the auxiliary
registers AR0 .. AR7 acting as
"pointers" to data memory, and control registers such as the
circular buffer register
(BK).
core.asm" file to initialize and control the
six-channel surround-sound board, and then copies the signal
from channel 1 of the six-channel board's A/D converter to
channels 1-3 of the D/A converters, and the signal from
channel 2 of the A/D to channels 4-6 of the D/A. Your
laboratory assistant should have a similar file for you to
use; this code block is provided here for example purposes
only.
thru.asm1 .copy "v:\54x\dsplib\core.asm" 2 3 .sect ".text" 4 main 5 ; Your initialization goes here. 6 7 loop 8 ; Wait for a new block of 64 samples to come in 9 WAITDATA 10 11 ; BlockLen = the number of samples that come from WAITDATA (64) 12 stm #BlockLen-1, BRC ; Repeat BlockLen=64 times 13 rptb block-1 ; ...from here to the ``block'' label 14 15 ld *AR6,16, A ; Receive ch1 16 mar *+AR6(2) ; Rcv data is in every other word 17 ld *AR6,16, B ; Receive ch2 18 mar *+AR6(2) ; Rcv data is in every other word 19 20 ; Code to process samples goes here. 21 22 sth a, *AR7+ ; Store into output buffer, ch1 23 sth a, *AR7+ ; ch2 24 sth a, *AR7+ ; ch3 25 26 sth b, *AR7+ ; Store into output buffer, ch4 27 sth b, *AR7+ ; ch5 28 sth b, *AR7+ ; ch6 29 30 block 31 b loop Figure 1 |
.sect ".text" The .sect directive
tells the assembler that the following lines are to be
placed in memory in the section named in its operand. There
are several sections defined in the assembly process; they
are used to define locations in memory at which certain
pieces of code or data must be placed.
.text, in which all of your
program code must be placed, and .data, in
which your program's data will be placed. The sect
".text" directive tells the assembler to place the
following code or data in program memory starting at
6000h; the sect ".data" directive
tells the assembler to place following code or data in data
memory starting at 1000h in memory. 1
.scratch section. Data placed in this short
section (32 words from 0060h to
007Fh in the data memory space; of these, the
first 6 locations are used by the core file and cannot be
used by your code) can be accessed quickly using opcodes,
such as stm, which are intended to access the
memory-mapped registers.
thru.asm code does not include a
.data section, your final FIR implementation
will have such a section to define where to place the states
or past input samples in addition to initializing memory for
the filter coefficients. In the linking process this data
section is assigned starting at the location
1000h in data memory.
core.asm file which initializes and configures
the DSP and supports the use of the D/A and A/D converters
on the six-channel board as well as the serial port on the
DSP evaluation board itself. For this lab, you will be using
only the D/A and A/D. If your laboratory assistant or lab
materials have not told you where to obtain this file, you
should ask for assistance at this time.
.text"
section. The ".text" section is internal
program RAM, and begins at 6000h. Your code
will begin somewhat after this, because the core file code
appears before your code in the assembled object file.
WAITDATA macro. Note that this
macro overwrites the B accumulator, so don't expect B to
stay the same across calls to WAITDATA! This
macro sets AR6 to the address of the input buffer, and AR7
to the address of the output buffer.
WAITDATA accumulates a block of 64
samples before it returns, Lines 12-13 set up a
loop that executes for BlockLen times. (The minus one is
required, because on the TI DSP a repeat loop runs one more
time than the number specified.) Line 12 sets
the BRC register, the Block
Repeat Counter, to 63, and Line 13 tells
the DSP to loop from the next location in memory (the
ld instruction on Line 15) to the
location immediately before the label "block." When you use
the rptb instruction, don't forget to include
the -1; otherwise, the DSP will execute an extra instruction
at the end of the loop.
ld *AR6,16,A loads the memory
location pointed to by AR6, the input buffer pointer, into
the high bits of A. (The 16 stands for a shift of 16 bits as
A is loaded.) The instruction mar *+AR6(2) adds
two to the value of AR6. The mar
instruction means Modify Address Register, and
allows you to do an address-register update without doing
any data loads or stores.
filter.asm file you will work
with in later modules has its sample-processing code at this
point, for example.
mar
directives are required; instead, the *AR7+
addressing mode is used to increment AR7 after each word is
written. The sth opcode writes the high-order
16 bits of A into memory. The stl opcode is
used to move the low-order 16 bits of the A accumulator into
memory. Be careful which you use; the two operations are
easily confused, and this has resulted in many hard-to-find
bugs in past students' code.
b opcode) back to the "loop" label, sending
the DSP back to before the call to WAITDATA to
await a new block of 64 samples.
firs" instruction described later, must be
placed in the ".text" section as it is required
to be located in program memory.Comments, questions, feedback, criticisms?