Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1

seku_495601
New Contributor II

How can Change Filter Co-eff During Run Time in PSOC5 LP Filter Block? any Examples

0 Likes
5 Replies
Vasanth
Moderator
Moderator

Hi,

Please checkout one way to do it. A function can be written for the purpose.

NOTE: Using this function requires the filter component to be set up with the same
type of filter (biquad or FIR) and number of taps/order as the coefficients being
loaded here.

*/
void Filter_LoadCoefficients(uint8 *pFiltCoeffs, uint16 wSize, uint16 wOffset) 
{
	/* This is the externally defined null array we will 
	use to clear out the sample data in RAM */
	extern const uint8 CYCODE Filter_data_a[];
	
    /* Power on DFB before initializing the RAMs */
    Filter_PM_ACT_CFG_REG |= Filter_PM_ACT_MSK;

    /* Turn off Run Bit */
    Filter_CR_REG &= ~Filter_RUN_MASK;
                
    /* Enable the DFB RAMS */
    Filter_RAM_EN_REG = Filter_RAM_DIR_BUS;
        
    /* Put DFB RAM on the bus */
    Filter_RAM_DIR_REG = Filter_RAM_DIR_BUS;
        
    /* DAta RAMs */
	
    /* Clear out the RAM which contains the sample values 
	from the previously operating filter */
	memcpy(Filter_DA_RAM,
        Filter_data_a, Filter_DA_RAM_SIZE); 
    
	/* This one copies wSize bytes of filter coefficients at the specified offset in the data B RAM  */
	memcpy(Filter_DB_RAM+wOffset,
        pFiltCoeffs, wSize); 

    /* Take DFB RAM off the bus */
    Filter_RAM_DIR_REG = Filter_RAM_DIR_DFB;

    /* Set up interrupt and DMA events */
//    Filter_SetInterruptMode(Filter_INIT_INTERRUPT_MODE);
//    Filter_SetDMAMode(Filter_INIT_DMA_MODE);
        
    /* Clear any pending interrupts */
    /* Bits [2..0] of this register are readonly. */
    Filter_SR_REG = 0xf8;   
}

Best Regards,
Vasanth

 

seku_495601
New Contributor II

My Co-eff are as follows

 

Final coefficients for Biquad filter :
Coefficients are in the order A0, A1, A2, B1 and B2

0.24254298210144
-0.485085725784302
0.24254298210144
-1.93959474563599
0.941091299057007

0.966162204742432
-1.93232417106628
0.966162204742432
-1.93157911300659
0.933069467544556

0.963419437408447
-1.92683911323547
0.963419437408447
-1.92609620094299
0.927582025527954

0.962027311325073
-1.92405486106873
0.962027311325073
-1.92331290245056
0.92479681968689

0.975322961807251
-1.9506459236145
0.975322961807251
-1.94989371299744
0.951398134231567

0.981450796127319
-1.96290183067322
0.981450796127319
-1.96214485168457
0.963658571243286

0.988350868225098
-1.97670149803162
0.988350868225098
-1.97593927383423
0.977463722229004

1.99156522750854
-3.98313045501709
1.99156522750854
-1.99079728126526

 

How can i use that one?  what is Offset  Value?

0 Likes
Len_CONSULTRON
Honored Contributor II

seku,

Are you talking about the Digital Filter Block (DFB) or the analog Low-pass filters (LPF)?

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
ARH
New Contributor II

Im just glad to see that someone is using the DFB... 

0 Likes
seku_495601
New Contributor II

i Need Both example with Dynamic Loading or changing Filter Co-eff

0 Likes