Digital Signal Processing Reference
In-Depth Information
N
-
1
 0
() =
(
) =
() +
(
) +◊◊◊+
(
(
)
)
yn
hxn i
-
h xn
hxn
-
1
h
xn
-
N
-
1
i
0
1
N
-
1
i
=
i ) represents the input sequence. The original input sequence, x , can
then be recovered, using ˆ ( n ) as an estimate of x ( n ), or
where x ( n
-
N
-
 1
1
() -
(
)
ˆ
yn
hxn i
-
i
ˆ
() =
xn
i
=
h
0
Build this project as FIRinverse . Use noise as input (from Goldwave or from
a noise generator, or modify the program to use the pseudorandom noise sequence,
etc.). Verify that the output is the input noise sequence, with the slider in position
1 (default). Change the slider to position 2 and verify the output as an FIR band-
pass filter centered at 1 kHz. With the slider in position 3, the inverse of the FIR
filter is calculated, so that the output is the original input noise sequence.
Example 4.11: FIR Implementation Using C Calling an
ASM Function ( FIRcasm )
The C program FIRcasm.c (Figure 4.31) calls the ASM function FIRcasm-
func.asm (Figure 4.32), which implements an FIR filter.
Build and run this project as FIRcasm . Verify that the output is a 1-kHz FIR
bandpass filter. Two buffers are created: dly for the data samples and h for the
filter's coefficients. On each interrupt, a new data sample is acquired and stored at
the end (higher-memory address) of the buffer dly . The delay samples and the filter
coefficients are arranged in memory as shown in Table 4.3. The delay samples are
stored in memory starting with the oldest sample. The newest sample is at the end
of the buffer. The coefficients are arranged in memory with h(0) at the beginning
of the coefficient buffer and h ( N
1) at the end.
The addresses of the delay sample buffer, the filter coefficient buffer, and the size
of each buffer are passed to the ASM function through registers A4, B4, and A6,
respectively. The size of each buffer through register A6 is doubled since data in
each memory location are stored as bytes. The pointers A4 and B4 are incremented
or decremented every two bytes (two memory locations). The end address of the
coefficients' buffer is in B4, which is at 2 N
-
1.
The two 16-bit load (LDH) instructions load the content in memory pointed by
(whose address is specified by) A4 and the content in memory at the address spec-
ified by B4. This loads the oldest sample and last coefficient, x ( n
-
-
( N
-
1)) and
h ( N
-
1), respectively. A4 is then postincremented to point at x ( n
-
( N
-
2)), and
B4 is postdecremented to point at h ( N
2). After the first accumulation, the oldest
sample is updated. The content in memory at the address specified by A4 is loaded
into A7, then stored at the preceding memory location. This is because A4 is
-
Search WWH ::




Custom Search