Digital Signal Processing Reference
In-Depth Information
mulate in A8. One can save the content of AMR at the end of processing one buffer
and restore it before using it again with a pair of
MVC
instructions:
MVC AMR,Bx
and
MVC Bx,AMR
using a B register.
Build and run this project as
FIRcirc
. Verify an FIR bandpass filter centered
at 1750 Hz. Halt, and Restart the program.
Place a breakpoint within the ASM function
FIRcircfunc.asm
at the branch
instruction to return to the calling C function (
B B3
). View memory at the address
delays
and verify that this buffer of size 256 is initialized to zero. Right-click on
the memory window to toggle “Float in Main Window” (for a better display). Run
the program. Execution stops at the breakpoint. Verify that the newest sample (16
bits) is stored at the end (higher address) of the buffer (at
0x3FE
and
0x3FF
).
Memory location
0x400
(in A9) contains the address
0x301
, where the subsequent
new sample is to be stored. This address represents the starting address of the buffer.
View the core registers and verify that A7 contains this address.
Run the project again and observe the new sample stored at the beginning of the
buffer. This 16-bit data sample is stored at
0x300
and
0x301
. Animate now and
observe where each new sample is being stored in memory. Note that A7 is incre-
mented to
0x303
,
0x305
,...The circular method of updating the delays is more
efficient. It is important that the buffer is aligned on a boundary with a power of 2.
While a buffer may be “naturally aligned,” one must make sure that it is (an address
with LSBs as zeros) if such buffer is to be used as circular.
Example 4.14: FIR Implementation Using C Calling an ASM Function
Using a Circular Buffer in External Memory (
FIRcirc_ext
)
This example implements an FIR filter using a circular buffer in external memory.
The same C source program
FIRcirc.c
and
ASM
function
FIRcircfunc.asm
as in the previous example are used, but with a modified linker command file.
This linker command file
FIRcirc_ext.cmd
is listed in Figure 4.37. The section
circdata
designates the memory section
buffer_ext
, which starts in external
memory at
0x80000000
.
Build this project as
FIRcirc_ext
. Load the executable file and view the
memory at the address
delays
. This should display the external memory section
that starts at
0x80000000
. Verify that the circular buffer is in external memory,
where all the delay samples are initialized to zero. Place a breakpoint as in Example
4.13, run the program up to the breakpoint, and verify that the newest input sample
is stored at the end of the circular buffer at
0x800000FE
and
0x800000FF
. Reg-
ister A9 contains the last address, and register A7 contains the address where the
subsequent 16-bit input sample is to be stored (
0x80000001
). Run the program
again (to the set breakpoint) and verify that the subsequent acquired sample is
stored at the beginning of the buffer at the address
0x80000001
. Remove the
breakpoint, Restart/run, and verify that the output is the same FIR bandpass filter
centered at 1750 Hz, as in Example 4.13.
Search WWH ::
Custom Search