Hi!We're trying to use the CMSIS DSP library to filter a real-time signal using the CMSIS dsp fir function. We are using the STM32746ZG board.
We've calculated the coefficients in C and they are correct according to MATLAB. We're feeding these into the arm_fir_init_f32() and we cannot get it to work. When the filter order is 2, i.e. coefficients are 0,1,0 - The output is the same as the input. When we increase the order the output becomes mostly noise. The filter coefficients doesn't seem to be used at all.
Buffer definitions:
float32_t ADCBUFFER[length]={0};
float32_t DACBUFFER[length]={0};
ADCBUFFER and DACBUFFER are circular buffers using DMA with length = 1000.ADC init:
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DMAContinuousRequests = ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
DAC init:
sConfig.DAC_Trigger = DAC_TRIGGER_T6_TRGO;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
TIM6 init:
htim6.Instance = TIM6;
htim6.Init.Prescaler = 0;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = tim6Period;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
System clock: 192MHzHCLK: 192MHzAPB1 peripheral clocks: 12MHzAPB1 timer clocks: 24MHzAPB2 peripheral clocks: 48MHzAPB2 timer clocks: 96MHz
Using DSP FIR:
float32_t * firStateF32 = calloc(sizeof(float32_t) * (blocksize+numTaps-1), 1);
arm_fir_instance_f32 S;
arm_fir_init_f32(&S, numTaps, filterCoeff, firStateF32, blockSize);
while (1)
{
arm_fir_f32(&S, ADCBUFFER, DACBUFFER, blockSize);
}
free(firStateF32);
The array filterCoeff is generated by another function (using sample rate = 800kHz) and ordered as described in the CMSIS DSP lib info.
What is missing to get the arm_fir_f32() to work properly?Thanks in advance!