Change filter coefficients of the DFB in runtime

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
WoKi_264666
Level 3
Level 3
First like received

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!

0 Likes
3 Replies