⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_iir_df1.c

📁 ADI BF535 DSP IIR滤波算法汇编优化源码
💻 C
字号:
/*******************************************************************************
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved.
Developed by Joint Development Software Application Team, IPDC, Bangalore, India
for Blackfin DSPs  ( Micro Signal Architecture 1.0 specification).

By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software. 
********************************************************************************
File Name   : test_iir_df1.c
Description : This module tests the iir_df1 function.
*******************************************************************************/
#include "mds_def.h"
#include "tiir_df1.h"

int error_flag = 0;
void (*f1)();
int cycle_count[10];

extern void _iir_df1(const fract16 [], fract16 [], int, iir_state_fr16 *);

void main()
{
    fract16 energy;
    fract32 acc=0;
    int i, nsamples, nstages;
    int error = 0;
    iir_state_fr16 s;

    f1 = _iir_df1;  

/**************************************************************************
Test : Multiple Value Test (Fourth Order, N % 2 = 0)
Description: Coefficients for a fourth order low pass filter generated using 
Matlab will be passed to the iir_df1 routine. . The entire array is passed to 
the routine. The energy of the filtered output using the iir_df1 routine and 
Matlab are compared.
***************************************************************************/

    nsamples = BUFFER_SIZE;
    nstages = 2;
    
    for (i = 0; i < DELAY_SIZE; i++)
        delay[i] = 0;
    
    iir_init(s, c, delay, nstages);

    // Store the Input samples having a frequency in the pass band 

    for(i=0;i<nsamples;i++)
        in[i] = INPPASS[i]; 

// Test2a finds iir biquad filter output for Ni/2 samples and dslay line gets 
// updated.
// Test2b finds iir biquad filter output for the next Ni/2 samples with the 
// delay line previously updated by test2a.    

    cycle_count[0] = Compute_Cycle_Count(in, out, nsamples/2, &s);
                                //This function inturn calls iir_df1()
                                // Test 2a

    cycle_count[1] = Compute_Cycle_Count(&in[nsamples/2], &out[nsamples/2], 
                                         nsamples/2, &s);
                                //This function inturn calls iir_df1()
                                // Test 2b


    // Check the energy of the output 
    acc = 0;

    for(i=0;i < nsamples;i++)
        acc += (out[i] * out[i]);
    
    energy = (acc>> NBITS1); // Store accumlated power in fract16 format  

    error = thresh - energy;
    if(error < 0)
        error = -error;
       
    if ( error > MAX_PERMISSIBLE_ERROR )
    {
            error_flag = error_flag | 1;
    }
    #ifdef PRINTF_SUPPORT
        if(error_flag & 1)
            printf("Test Case failed\n");
        else
            printf("Test Case passed\n");
    #endif
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -