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

📄 iir16d.c

📁 TMS320X281x滤波库源码及测试程序
💻 C
字号:
/* ==============================================================================

System Name:  IIR Filter Demo, This system uses IIR5BIQ16 (16 bit implementation) module

File Name:    IIR16D.C

Description:  Primary System file for demonstrating the IIR Filter

Originator:   Digital control systems Group - Texas Instruments

Target dependency:  C28x

Description:
============

This software demonstrates the IIR Filter Usage

   The frame work, for demonstrating the FILTER is given below
   
   
   CH0  |--------------|           |------------|               |-----------|
   ---->|              |           |            |               |           |
   CH0  |              |           |            |               |           |         
   ---->|              |     input |            | Output        |  EVMDAC   |
   CH0  |   ADC04U_DRV |-----|---->|    IIR     |-------------->|  PWMDAC   |
   ---->|              |     |     |   FILTER   |               |  DATALOG  |
   CH0  |              |     |     |            |          |--->|           |
   --|->|              |     |     |            |          |    |           |
        |--------------|     |     |------------|          |    |-----------|
                             |                             |
                             |-----------------------------|
 
*/


#include <sgen.h>
#include <dlog4ch.h>
#include <filter.h>


/* Create an instance of Signal generator module    */
SGENTI_1 sgen = SGENTI_1_DEFAULTS;

/* Create an instance of DATALOG Module             */
DLOG_4CH dlog=DLOG_4CH_DEFAULTS;      
    
/* Create an Instance of IIR5BIQD16 module and place the object in "iirfilt" section    */ 
#pragma DATA_SECTION(iir, "iirfilt");
IIR5BIQ16  iir=IIR5BIQ16_DEFAULTS;
                                                                  
/* =============================================================================
Modify the delay buffer size to comensurate with the no of biquads in the filter
Size of the Delay buffer=2*nbiq
==============================================================================*/ 
/* Define the Delay buffer for the cascaded 6 biquad IIR filter and place it in "iirfilt" section */
#pragma DATA_SECTION(dbuffer,"iirfilt");
int dbuffer[2*IIR16_LPF_NBIQ];

/* =============================================================================
Modify the array size and symbolic constant to suit your filter requiremnt.
Size of the coefficient array=5*nbiq
==============================================================================*/
/* Define the Delay buffer for the cascaded 6 biquad IIR filter and place it in "iirfilt" section */
       
const int coeff[5*IIR16_LPF_NBIQ]=IIR16_LPF_COEFF;
         
         
/* Finter Input and Output Variables                */   
int xn,yn;
     
void main()
{    


/* Signal Generator module initialisation           */ 
       sgen.offset=0;
       sgen.gain=0x7fff;        /* gain=1 in Q15                              */
       sgen.freq=9830;          /* freq = (Required Freq/Max Freq)*2^15       */
                                /*      = (3000/10000)*2^15 = 5369             */         
       sgen.step_max=0x7FFF;    /* Max Freq= (step_max * sampling freq)/65536 */
                                /* Max Freq = (32767*20k)/65536 = 10,000      */

/* DATALOG module initialisation                    */        
       dlog.iptr1=&xn;  
       dlog.iptr2=&yn;
       dlog.trig_value=0x800;
       dlog.size=0x400;         
       dlog.init(&dlog);

/* IIR Filter Initialisation                                */ 
        iir.dbuffer_ptr=dbuffer;
        iir.coeff_ptr=(int *)coeff; 
        iir.qfmat=IIR16_LPF_QFMAT;
        iir.nbiq=IIR16_LPF_NBIQ; 
        iir.isf=IIR16_LPF_ISF; 
        iir.init(&iir);
              

/*---------------------------------------------------------------------------
    Nothing running in the background at present           
----------------------------------------------------------------------------*/

        while(1) 
        {
            sgen.calc(&sgen);
            xn=sgen.out;
            iir.input=xn;           
            iir.calc(&iir);
            yn=iir.output;
            dlog.update(&dlog);
        }       

} /* End: main() */

             




⌨️ 快捷键说明

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