Help for lowpass filter

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help for lowpass filter

Jump to solution
1,074 Views
mr_max
Contributor IV

Hello !

It's not my first time here but I ask to my teachers and they can't help me because they never work with DSP at all. Freescale community and other forum are my only way to find help. So if I'm here it is because I'm stuck again ...

 

This time I tried to make a simple lowpass filter inspired by the technic from the Benchmark programme of the 56k user manuel.

The equation to implement is : Y(n) = 0.061*x(n) + 0.061*x(n-1) + 0.877*y(n)

 

Here is the code :

...

       move #000208,r4

       move #2,m4

       move #TableCoeff,r0

       do #3,_enddo      ;Load TableCoeff to y memory

        move y:(r0)+,a

        nop

        move a,y:(r4)+

_enddo                     ;end loadTableCoeff              

       move #000200,r0

       move #2,m0

       clr a

 

AudioLoop

 

       jclr #RightRx,x:LRFlag,*

       bclr #RightRx,x:LRFlag

       move       x:RxBuffBase,a    ; <- Input ADC left

       nop

 

       move       a,x:(r0)                                                

       rnd        a             x:(r0)+,x0   y:(r4)+,y0

       mpy        y0,x0,a       x:(r0)+,x1   y:(r4)+,y0   ; a = 0.061*x(n)

       mac        y0,x1,a       x:(r0)+,x0   y:(r4)+,y0  ; a = a + 0.061*x(n-1)

       macr       y0,y1,a                                 ; a = a + 0.877*y(n-1)

       move       x:(r0)+,x0  ; take out x(n)

       move       x0,x:(r0)+  ; x(n) -> x(n-1)

       move       a,x:(r0)+  ; y(n) -> y(n-1)


       move        a,x:TxBuffBase       ; a = y(n) -> DAC left output

       jmp AudioLoop

...

 

The memory mapping is :

 

X memory :

000200 : X(n)

000201 : X(n-1)

000202 : Y(n-1)

 

Y memory :

000208 : coefficient b0 (0.061)

000209 : coefficient b1 (0.061)

000210 : coefficient a1 (0.877)

 

When I test the code, I have an output signal but its amplitude not change with an increase of frequency. So what's wrong ?

 

Labels (1)
Tags (3)
0 Kudos
1 Solution
834 Views
mr_max
Contributor IV

I find the error. The ligne macr y0,y1,a use y1 register instead of x0. So now the lowpass filter work well and I can try a bandpass filter again.

View solution in original post

0 Kudos
3 Replies
835 Views
mr_max
Contributor IV

I find the error. The ligne macr y0,y1,a use y1 register instead of x0. So now the lowpass filter work well and I can try a bandpass filter again.

0 Kudos
834 Views
rocco
Senior Contributor II

Hi Maxime,

I have not analyzed your code yet, but at first glance it looks well structured. I have a few questions though.

What is the cutoff frequency supposed to be? What frequencies are you feeding it?

The amplitude should not change at all until you approach the cutoff frequency, at which point it should be attenuated about 3db. Could it be that you haven't reached the cutoff frequency yet? I can't tell what the cutoff should be, as I don't know the sample rate.

0 Kudos
834 Views
mr_max
Contributor IV

The cutoff frequency is about 1kHz and the sample frequency is 48kHz.

I tested the filter with an oscilscope :

At F.input < 1khHz

Input = 900mV

Output = +-160mV

I also tested the loading of coefficients table to Y memory and it work well.

But I remember that the Benchmark program of the 56k manuel divide all coefficients by 2. I did not divide it. Should I do it ?
This program is primarily used to teach me how to properly use the assembler technics. It treats the audio bandwidth

0 Kudos