Texas Instruments MSP50C6xx User Manual
Page 147
Special Filter Instructions
4-61
Assembly Language Instructions
theory requires). The second to last RAM location in the circular buffer is
tagged using an STAG instruction. Below is an example of how to set up circu-
lar buffering with FIR or COR.
When using the FIR or COR instruction with circular buffering, RAM needs to
be allocated for the circular buffer and the filter coefficients. Therefore, the filter
coefficient RAM locations must be loaded into RAM and the circular buffer
must be cleared before the first FIR or COR instruction is executed.
; Set up for FIR filtering (N = 3)
; First clear circular buffer and set tag of second to last
; sample
zac
a0
mov
r0,circBuff
;point to circular buffer
rpt
N–2
;repeat N times
mov
*r0++,a0
;clear RAM locations in circular
; buffer
mov
*r0,a0
;N+1 sample in buffer
mov
r5,2
;now step back one word and set tag
sub
r0,r5
;point r0 back to 2nd to last sample
; in buffer
stag
*r0
;set tag
; Second initialize filter coeffs to proper values
; –––––
NOTE: In this code, N must be less than 33 since
; –––––
there are only 32 accumulator registers!
mov
STR,N–2
;set string length to N
zacs
a0
;zero out N accumulators
mov
a0,FIR_COEFFS ;point to filter coeffs
movs
a0,*a0
;get N filter coeffs
mov
r0,coeffs
;point to RAM locs. for filter coeffs
movs
*r0,a0
;put filter coeffs into RAM locs.
mov
a0,circBuff
;set up pointer to start of circular
; buffer
mov
*startOfBuff,a0
; Initialize filterSTAT_tag (THIS IS IMPORTANT!)
rovm
;This line is MANDATORY!
sxm
;Sample values are signed
mov
*filterSTAT_tag,STAT
Three more details in the above example merit an explanation. The first detail
is the pointer to the start of the circular buffer (
startOfBuff
). This keeps
track of the location of the newest or current sample in the circular buffer. It
moves backwards by one location in the buffer each time the FIR or COR
instruction is executed so that the oldest sample in the buffer is overwritten with
the next sample. This backwards movement is also circular. For example, sup-
pose that
startOfBuff
points to the first RAM location of the circular buffer.