3 Replies Latest reply on Apr 10, 2015 5:17 PM by DaKn_263916

    Change filter coefficients of the DFB in runtime

    WoKi_264666

      Any time before there was a question on the forum: Can I change  the filter constants in runtime ?
      My answer is: Yes you can.

         

      Here is a code snippet that complains, how it works.

         

      void LoadFilter (uint8 fltr)// fltr is the pointer to the dedicated parameter block

         

      { // Put DFB RAM on the bus :

         

          Filter_RAM_DIR_REG = Filter_RAM_DIR_BUS;

         

      if (fltr == 1)

         

              cymemcpy(Filter_DB_RAM,Filter100_data_b, Filter_DB_RAM_SIZE);

         

      else if (fltr == 2)

         

              cymemcpy(Filter_DB_RAM,Filter200_data_b, Filter_DB_RAM_SIZE);

         

      else if (fltr == 3)

         

              cymemcpy(Filter_DB_RAM,Filter400_data_b, Filter_DB_RAM_SIZE);

         

      else if (fltr == 4)

         

              cymemcpy(Filter_DB_RAM,FilterTP2800_data_b, Filter_DB_RAM_SIZE);

         

      // Take DFB RAM off the bus :

         

      Filter_RAM_DIR_REG = Filter_RAM_DIR_DFB;

         

      }

         

          

         

      The Filter_data you can compute with the embedded filter wizard. After setting your parameters 

         

      in the Filter Block, build the application an then read out the file Filter:Ram_Data.c :

         

      const uint8 CYCODE Filter_data_b[] = 

         

      {

         

          0x14, 0xD0, 0x01, 0x00, 0x28, 0xA0, 0x03, 0x00,...

         


      And if you want to change the filter structure ( FIR --> IIR) you have to exchange in the same way the following matrix:

         


      const uint8 CYCODE Filter_control[] = 

         

      {

         

          0x20, 0x13, 0x00, 0x25, 0x61, 0x17, 0x80, 0x26,....

         


      Don't know why all filter coefficients are located in Filter_data_b, even when you use filter stage A... 

         


      Good luck!

        • 1. Re: Change filter coefficients of the DFB in runtime
          BoTa_264741

           Thank you for information. Can you post sample project  also?

             

          odissey1

          • 2. Re: Change filter coefficients of the DFB in runtime
            WoKi_264666

            Only a "big" program is available here, that includes the focused lines. 

               

            Please note: compiles with PSoC Creator 2.2, because I used a CY8CKit-014 with CY5588AXI.060-ES1.

               

            Interesting for the problem are:

               

            main.c      line 723 ...

               

            filters.c     complete

               

            main.h      line 13 ...

               

             

               

            Have fun!

            • 3. Re: Change filter coefficients of the DFB in runtime
              DaKn_263916

              On location of coefficients, from tech support -

                 

               

                 

                  

                 

                        

                 

              1. "Why, when doing a chan a and chan b filter, 64 taps each, does all the filter data show up in Filter_data_b[], none in Filter_data_a[] ?"

                 

               

                 

              The DFB has 2 data RAMs. One of the 2 RAM blocks is used to store the filter co-efficients of both the channels. And the other RAM block is used to store the intermediate data or the incoming samples.

                 

              That is the reason why both the channels' co-efficients are stored in the data RAM B.

                 

               

                 

              2. "Why are the arrays, both, defined as 32 coefficients ? Is that due to symmetry of response, so you only need 1/2 the coefficients ?"

                 

               

                 

              Yes.

                 

               

                 

              3. For the BiQuad also, the data RAM B will hold the co-efficients.

                 

               

                 

              Regards, Dana.