Page 377 - Analog and Digital Filter Design
P. 377
374 Analog and Digital Filter Design
filter coefficients. Data memory 300h to 3 1 1h has been reserved for signal data
(input from an analog to digital converter).
RPTZ #I6
MACD OFFOOh,*-.
The RPTZ #16 zeroes the accumulator and then causes the instruction
that follows to be repeated 17 times (do once, then repeat 16 times). MACD
{pma, ha} is a multiply and data move instruction. Before this instruction is
run an auxiliary register must be set as the data pointer; in this case we have
used AR3, because we ran the instruction MAR *,AR3. The pma is incremented
each time the instruction is repeated, so it starts at FFOOh and ends up at FFlOh.
The *- that replaces the dma is an instruction to use the data pointed to
by the auxiliary register, during the multiplication, and then decrement the
address. Thus the initial address in AR3 has to be the highest used during mul-
tiplication (310h), which is then decremented step by step to 300h for the last
multiplication.
The address FFOOh was used as the pma and was located in memory block 0.
The 17 FIR filter coefficients were stored here, starting at address FFOOh. The
dma was in block 1; note that in order to use block 1 as data memoiy, rather
than program memory, the CNF bit must be set. Eighteen 16-bit words were
reserved when the program was assembled (.space 120h), beginning at address
300h. Seventeen addresses were used to store a history of previous input data,
and these were multiplied by the 17 coefficients.
In the program, each MACD instruction moved previous samples of input data
to the next highest address. Seventeen previous input samples were needed to
multiply by the filter coefficients. However, 18 spaces were reserved in the
program for input data samples (in assembler this is denoted by space 120h).
This was because data in the highest address used by the instruction MACD
(310h) was moved to the next highest address (31 lh). Data in address 311h did
not take part in any further processes; this address is a waste bin!
After a repeated multiplication the accumulator and the product register must
be added, to add the last result to the previous ones. Finally, the data must be
shifted left by one bit to put the upper half of the accumulator in Q15 format,
instead of 430, and then stored. This final action is a single instruction. In the
'(250 DSP these instructions are:
APAC ; add product register and accumulator
SACH REG,] ; shift left one bit and store result in register REG.

