Thought this would deserve a separate post on its own.

What's going on is that I finally got my low pass digital filter working on the STM32H753ZI using the PMODI2S2 peripheral and I noticed the output signal is extremely low ~340mVpp this is after the biquad filtering. If I take out the low pass filtering the output signal then raises to around ~600mVpp.

What's causing this phenomenon? The digital filter bode plot says the gain from very low frequencies up to the cut off is 0dB so I dont understand whats going on. The only thing I can think of is the biquad filter is causing an attenuation perhaps?

Analog Filter: $$ LPF_{Analog}=\frac{3.94e07}{s^2+8889s+3.94e07}$$

enter image description here]3

Digital Filter: using tustin $$ LPF_{Digital}=\frac{0.00102z^2 +0.002041z+0.00102}{z^2-1.908z+0.9116}$$

enter image description here


Input signal(yellow) from wave gen and output signal(green) after the Biquad filter enter image description here

Input signal(yellow) from wave gen and output signal(green) passthrough with the peripheral no digital processing enter image description here

Bode plot from Oscilloscope with the biquad filter: enter image description here


#define ARM_MATH_CM7

#include "main.h"

#include "arm_math.h"

void init_Clock(void);
void init_I2S(void);
void init_Debugging(void);
void init_Interrupt(void);
void init_SpeedTest(void);

int32_t RxBuff[4];
int32_t TxBuff[4];
uint8_t TC_Callback = 0;
uint8_t HC_Callback = 0;

char uartBuff[8];
 float32_t iir_coeffs[5] = {0.00102f, 0.002041f, 0.00102f, 1.908f, -0.9116f}; //B0, B1, B2, A1, A2
float32_t iir_mono_state[4];

float32_t Rx_Buff_f[4];
float32_t Rx_Buff_f_out[4];

arm_biquad_casd_df1_inst_f32 monoChannel;

void DMA1_Stream0_IRQHandler(void) {

    if (((DMA1 -> LISR) & (DMA_LISR_TCIF0)) != 0){
        DMA1 -> LIFCR |= DMA_LIFCR_CTCIF0;
        TC_Callback = 1;

    else if (((DMA1 -> LISR) & (DMA_LISR_HTIF0)) != 0){
         DMA1 -> LIFCR |= DMA_LIFCR_CHTIF0;
         HC_Callback = 1;


int main(void) {

    arm_biquad_cascade_df1_init_f32(&monoChannel, 1, iir_coeffs, iir_mono_state);

  while (1)

      if (HC_Callback == 1){

         // GPIOA->BSRR |= GPIO_BSRR_BS3_HIGH;

          for (int i = 0; i < 2; i++){
              Rx_Buff_f[i] = (float32_t)RxBuff[i];

          arm_biquad_cascade_df1_f32(&monoChannel, Rx_Buff_f, Rx_Buff_f_out, 2);

          for (int i = 0; i < 2; i++){
                TxBuff[i] = (int32_t)Rx_Buff_f_out[i];

          HC_Callback = 0;

      } else  if (TC_Callback == 1){

        //  GPIOA->BSRR |= GPIO_BSRR_BR3_LOW;

          for (int i = 2; i < 4; i++){
               Rx_Buff_f[i] = (float32_t)RxBuff[i];

                  arm_biquad_cascade_df1_f32(&monoChannel, &Rx_Buff_f[2], &Rx_Buff_f_out[2], 2);

                  for (int i = 2; i < 4; i++){
                        TxBuff[i] =  (int32_t)Rx_Buff_f_out[i];

          TC_Callback = 0;



  • $\begingroup$ Have you tried using the filter with a gain of 1. I.e set b0 to 1, b1, b2, a1, a2 to 0. ? This looks more like a data format issue $\endgroup$
    – Ben
    Oct 15 '20 at 20:27
  • $\begingroup$ Tried with all the coefficients to 1, it breaks the thing theres no output, however I noticed there's a filter network on the I2S peripheral directly, this could be the reasoning. reference.digilentinc.com/_media/reference/pmod/pmodi2s2/… $\endgroup$
    – Pllsz
    Oct 15 '20 at 20:30
  • $\begingroup$ setting all coefficients to 1 is not a good idea... $\endgroup$
    – Ben
    Oct 15 '20 at 20:39
  • $\begingroup$ To convert your filter to a DC gain of 1, set b0 to 1 AND b1, b2, a1, a2 to 0. $\endgroup$
    – Ben
    Oct 15 '20 at 20:39
  • 1
    $\begingroup$ @Ben Ill take fault there. However what I posted about the I2S Peripheral device having a band pass filter, that could cause the attenuation then right? What doesnt make sense to me right now is that having the biquad have a gain of just 1 gives me an output voltage of 600mV, that make sense due to the RC bandpass network, however when using my digital filter is further attenuated to 340mV? My filter should have a DC gain of 1 so I should still see 600mV ? $\endgroup$
    – Pllsz
    Oct 15 '20 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.