Using CMSIS DSP on STM32F746ZG for FIR filtering


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.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;


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: 192MHz
HCLK: 192MHz
APB1 peripheral clocks: 12MHz
APB1 timer clocks: 24MHz
APB2 peripheral clocks: 48MHz
APB2 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); 



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!

No Data
  • This picture shows the array filterCoeff, fs=8000, fc=2000, lowpass, blackman window.

    The generated coefficients are the same as given by the FIR window method in MATLAB.

    The picture below shows input ADCBUFFER (blue) and output DACBUFFER (yellow) for an order two high pass filter. The input frequency is 1kHz and the cutoff frequency is 50kHz. The output is not attenuated as expected.

    The picture below shows the same but with the filter order increased to 6.

No Data