User manual

mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
637
FIR_Radix
Prototype
sub function FIR_Radix(dim FilterOrder as word, dim ptrCoeffs as longint,dim
BuffLength as word, dim ptrInput as word, dim Index as word) as word
Description This function applies FIR lter to ptrInput.
Parameters - FilterOrder: order of the lter + 1
- ptrCoeffs: pointer to lter coefcients in program memory
- BuffLength number of input samples
- ptrInput: pointer to input samples
- Index: index of current sample
Returns
with:
N - buffer length
k - current index
Requires Nothing.
Example
const BUFFFER_SIZE = 32
const FILTER_ORDER = 20
const COEFF_B as integer[FILTER_ORDER+1] = (
0x0000, 0x0048, 0x0133, 0x02D3, 0x052B, 0x0826,
0x0BA0, 0x0F62, 0x1329, 0x16AA, 0x199A, 0x16AA,
0x1329, 0x0F62, 0x0BA0, 0x0826, 0x052B, 0x02D3,
0x0133, 0x0048, 0x0000
)
dim input as word[BUFFFER_SIZE] ydata ‘ Input buffer
inext as word ‘ Input buffer index
...
dim CurrentValue as word
CurrentValue = FIR_Radix(FILTER_ORDER+1, ‘ Filter order
word(@COEFF_B), ‘ B coefcients of the lter
BUFFFER_SIZE, ‘ Input buffer length
word(@input), ‘ Input buffer
inext) ‘ Current sample
Notes Input samples must be in Y data space.
FIR Filter Library
mikroBasic PRO for dsPIC30/33 and PIC24 includes a library for nite impulse response (FIR) lter. All routines work
with fractional Q15 format.
A nite impulse response (FIR) lter is a type of a digital lter, whose impulse response (the lter’s response to a delta
function) is nite because it settles to zero in a nite number of sample intervals.
Library Routines
- FIR_Radix