AnsweredAssumed Answered

FIR filter Block Based Talk Thru 21369 EZ-kit

Question asked by toebs on Sep 14, 2011
Latest reply on Oct 17, 2011 by Mitesh



I have never before programmed on a DSP, so i might have missed something obvious, but here is my problem:


I am trying to implement a FIR filter in the Block Based Talk Thru example for the 21369.
My delay line (temp) and my FIR filter seems to work when i use my debug code.

But when i run the program with an input whitenoise the output is not filtered as it should be.

I think the problem has to do with the numberformat used in the unsigned int, negative numbers, and the DAC.


Any help will be greatly appreciated.


P.S. Pardon broken english, it is not my native


This is the code from the blockProcess.c



#include "tt.h"
#include <filter.h>
// Place the audio processing algorith here. The input and output are given
// as unsigned integer pointers.
#define M 4
int n;
int i;
int k;
int u;
float b[] = {0.25, 0.25, 0.25, 0.25};
float old[M-1] = {0};
void processBlock(unsigned int *block_ptr)
float out_temp[NUM_SAMPLES] = {0};
//Clear the Block Ready Semaphore
blockReady = 0;
//Set the Processing Active Semaphore before starting processing
isProcessing = 1;
    //Variabel til delay line
    float temp[NUM_SAMPLES + M - 1] = {0};
//Set: First M-1 samples in temp to be the last M-1 samples from the block previously processed
temp[i] = old[i];
    //Fill the rest of temp with the samples from the current processing block
         temp[i+M-1] = ((signed int) (block_ptr[i] << 8)) >> 8;
    //store last M-1 sample form the current processing block
         old[i] = ((signed int) (block_ptr[NUM_SAMPLES-M+i+1] << 8)) >> 8;//block_ptr[NUM_SAMPLES-M+i+1];
//FIR filter
         float fold = 0.0f;
              #if USE_DEBUG_CODE
              out_temp[n-M+1] = out_temp[n-M+1] + b[k] * temp[n-k];
              fold += b[k] * temp[n-k];
         block_ptr[n-M+1] = (unsigned int) (fold + 0.5f);
    isProcessing = 0;