# Quick question about FIR filters

**URL:** <https://discourse.myriadrf.org/t/quick-question-about-fir-filters/2386>\
**Category:** LimeSDR\
**Created:** [23 February 2018 16:07 UTC](https://discourse.myriadrf.org/t/quick-question-about-fir-filters/2386 "2018-02-23T16:07:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DasSidG](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@DasSidG](https://discourse.myriadrf.org/u/DasSidG)\
**Post date:** [23 February 2018 16:07 UTC](https://discourse.myriadrf.org/t/quick-question-about-fir-filters/2386/1 "2018-02-23T16:07:27Z")

</div>

Hi all,

I’m interested in using the general purpose FIR filters onboard the LimeSDR to do some basic rectangular filtering. In GNU Radio if I carry out the filtering the latency increases too much for my application.

I’ve identified the function which I believe would be used to set the filter coefficients [here](https://github.com/myriadrf/LimeSuite/blob/41ec4d8ccbf7de58c69d6976e3c4df2372a71fe6/src/lms7002m/LMS7002M.cpp#L1733). However, there’s a slightly concerning comment above stating

‘This function does not change GFIR\*\_L or GFIR\*\_N parameters, they have to be set manually’

Looking at the LMS7002M datasheet, to me it seems like GFIR\*\_L is referring to the filter length (= N/5, where N is the number of filter taps), and GFIR\*\_N is the number of filter taps.

I want to use a filter with 84 taps, all with magnitude 1, in the RX chain. I know I need to use filter 3 because that is the only filter which can deal with more than 40 taps. My questions are:

1. Have I understood correctly? Do I need to use N = 85, and L = 17, and just set that last extra filter tap to 0?
2. How do I set L and N for filter 3 for the receive path? I couldn’t find a specific function for it, and I’m not really familiar enough with the API to know how to do it unfortunately.

I’m guessing this can’t be done through Soapy or GNUradio or anything like that, so my plan is to shove this command in the constructor in the SoapyLMS7 API.

Thanks!  
DasSidG

---

<div class="post-metadata">

**Author:** ![DasSidG](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@DasSidG](https://discourse.myriadrf.org/u/DasSidG)\
**Post date:** [2 March 2018 11:35 UTC](https://discourse.myriadrf.org/t/quick-question-about-fir-filters/2386/2 "2018-03-02T11:35:35Z")

</div>

Ok, so after having done a bit more research I seem to be able to somehow edit the filter coefficients, but I’m not getting the results I expect. I now undestand that for 84 taps in GFIR 3 I need to set N to 90 (a multiple of 15), and set L to roundUp(90/15)-1 = 5.

I am using quite an old version of the drivers, at commit (22nd Nov 2017, browse [here](https://github.com/myriadrf/LimeSuite/tree/0167e645535e366f76fcd5d0ea986af37b630b72). This is because I have modified them in a few ways to get my application to work, and if I try to pull a recent version then because of the restructured limesuite those fixes dont work. What I have tried is adding the following lines [here](https://github.com/myriadrf/LimeSuite/blob/0167e645535e366f76fcd5d0ea986af37b630b72/SoapyLMS7/Settings.cpp#L1397):

```
rfic->Modify_SPI_Reg_bits(LMS7param(GFIR3_N_RXTSP), 90); // N=90
rfic->Modify_SPI_Reg_bits(LMS7param(GFIR3_L_RXTSP), 5); // Set L to 5 as N = 90 (L = roundUp(N/15)-1 for GFIR3)

```

and I added the following line [here](https://github.com/myriadrf/LimeSuite/blob/0167e645535e366f76fcd5d0ea986af37b630b72/SoapyLMS7/Streaming.cpp#L212)

```
writeSetting(SOAPY_SDR_RX, 0, "ENABLE_GFIR_LPF", "0,90,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0");

```

I’ve tried various filter lengths, e.g. with all zeros to check if I get a zero output, and in general the results are not what I expect, althought htey are different from if I don’t attempt anything at all. Would anyone be able to point out where I’ve gone wrong?

Thanks!

DasSidG
