DSPRelated.com
Forums

VisualDSP++ 2.0 (ADSP-218x) -- fir.asm broken?

Started by Unknown June 15, 2001


Has anybody been using the function fir() in VisualDSP++?

I just started testing it this morning and I haven't been able to get repeatable
results running it multiple times against the same data set.

It seems to be seriously broken.

In the below pseudocode, I'd expect the output of the filter, pfiltered, to be
identical for each channel/sample, but it's not.

A cursory examination of fir.asm suggests that the delay line isn't working
correctly.

extern int AI_raw[NUM_CHAN_TO_FILTER][NUM_OF_SAMPLES];
extern int AI_filtered[NUM_CHAN_TO_FILTER][NUM_OF_SAMPLES];

int ai_filter(void)
{
static int chan, sample;
static int *punfiltered, *pfiltered;
static int filter_state[NUM_CHAN_TO_FILTER][12+1];
static int pm filter_coeffs[12] =
{FILTER_COEFF11, FILTER_COEFF10, FILTER_COEFF9,
FILTER_COEFF8, FILTER_COEFF7, FILTER_COEFF6,
FILTER_COEFF5, FILTER_COEFF4, FILTER_COEFF3,
FILTER_COEFF2, FILTER_COEFF1, FILTER_COEFF0};
static int adc_sample[12] = {479, 411, 232, -8, -247, -419, -479, -411, -232,
8, 247, 419};

for (sample = 0; sample < NUM_OF_SAMPLES; sample++)
{
for (chan = 0; chan < NUM_CHAN_TO_FILTER; chan++)
{
AI_raw[chan][sample] = adc_sample[sample];

punfiltered = &AI_raw[chan][sample];
pfiltered = &AI_filtered[chan][sample];
*(pfiltered) = fir(*(punfiltered), filter_coeffs,
filter_state[chan], 12) *
FILTER_GAIN;
}

}



Filter state buffer must be great than samples*2. Set pfilter_state at middle of state buffer.