2022-10-05 02:19 PM
Hi all,
I am working with CMSIS DSP alghoritms and currently I get stuck with FIR and iir filters
When data are predefined in float32_t arrays everything works fine like bellow for FIR lpf
But when i am trying to use the same filter for array from ADC it looks like below (something wierd on right side of second graph):
Same input data for hpf IIR filter and again something wierd on right side of graph
Another problem is when I am trying to use real time filter (one element arrays) it looks like FIR and IIR do nothing and don't react on frequency change
ADC and DAC are triggered 20 kHz and tested analog signal in ADC_IN5 500 Hz
FIR and IIR coeff. are calculated by python scipy firwin and iirdesign functions
Main code attached also header files with adc, dac, etc.
Thank You in advance for your time
2022-10-06 03:53 AM
To me, it looks like an issue with DAC. In this situation, I checked:
a) does the circular mode work correctly? (Is there a relation between right side and DAC samples?)
b) enable DMA user error
c) enable DAC DMA underrun interrupt
In my tests on the STM32U585, the underrun and a bus error hardfault were triggered - no matter what I did (priorities, trigger timer setting...).
My solution was to use DAC with DMA and DMADOUBLE buffering (using DWORD or 32bit width, with DHR12R1 as target). Careful: when you do not want to use DMA (e.g. when testing with builtin wave sources), disable DMA and DMADOUBLE buffering.
2022-10-07 05:30 PM
Thank You Andreas - You are Great. I have to learn lot about registers...
BTW finally i have added two lines:
DMA1_Stream5->PAR=(uint32_t)&(DAC->DHR12R1);
DMA1_Stream5->M0AR=(uint32_t)filtered_array
For now i have checked for FIR and it works perfect- tommorow tests for IIR but I am 100% sure it will work to.
Thanks once again!
2022-10-10 08:38 AM
Hi @SCies.1,
I suggest you look to the X-CUBE-DSPDEMO firmware package. It includes FIR & FFT examples.
That may be helpful for you.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-10-11 02:01 AM
@SCies.1 Could you write which MCU you use?
It's pretty cool that it works, despite the fact that we use different MCUs...
2022-10-12 01:55 AM
@Andreas Köpke I am working on STM32F746ZG board. Back to subject - my enthusiasm was to quick- results looked good but it only seems to be right one- it is probably my lack of knowledge about regisers. Anyway- i found the reason of error. In my code I am sampling an array then stop ADC, count FIR / IIR and send it through DAC with circular mode. Problem was ADC restart- because of time delay sampling was initialized somewhere in middle of DAC cycle.
Solution was to start ADC and DAC line by line and lift up IIR response cos it shows only positive values. Now results for lpf FIR and hpf IIR looks like below.
the only problem i am dealing with now is real time filtering one sample array- despite data are the same as above (types, filters etc.) both filters gives "0" in answer. Tomorrow I'll check Amel package maybe there will be some helpful stuff