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

📄 wdf_ex2.c

📁 Wave Digital Filtering Using the MSP430
💻 C
字号:
/******************************************************************************
;   Lattice Wave Digital Filter to perform High Pass filtering
;
;   Description: This code calls a Lattice Wave Digital Filter assembly function 
;                wdf_ex2 and obtains the gain for frequency starting from 50Hz
;                to 3950 Hz. The filter coefficients conform with the HPF 
;                specifications of Example 2 in the Application Report. 
;
;   Note:        This code assumes 32.768 KHz XTAL on LFXT1 on the MSP430FG439 
;
;   K. Venkat
;   Texas Instruments Inc.
;   August 2006
;   Built with IAR Embedded Workbench Version: 3.41A
;*******************************************************************************/

#include "sine_data_ex2.dat"  
#include  <stdio.h>
#include  <msp430xG43x.h>
int wdf_ex2(int);
void DCO();
int delay0,delay1, delay2,delay3,delay4,delay5,delay6,delay7,delay8,
    delay9, delay10,input,output; 
int i,outer_loop; 
float sum=0,gain[44],finalout;

main()
{
      WDTCTL = WDTPW + WDTHOLD;         // Stop WDT
      FLL_CTL0 |= XCAP18PF;             // Configure load caps
      DCO();                            // Configure the CPU MCLK to 8 MHz
      for (outer_loop=0;outer_loop<44;outer_loop++)
      {
          delay0=0;                     //   Delay elements initialized to zero
          delay1=0;                     //   at the start of each frequency
          delay2=0; 
          delay3=0;
          delay4=0; 
          delay5=0;
          delay6=0; 
          delay7=0;
          delay8=0;
          delay9=0;
          delay10=0;
          sum=0;
          for (i=0;i<400;i++)           //  400 samples for each frequency
          {
              input=(data[(outer_loop)*400+i]);
              wdf_ex2(input);           //  Wave Digital filter called for each 
                                        //  sample to output one sample  
              finalout=output/2047.0;   //  Converted to Floating point before 
                                        //  gain calculation 
              sum=sum+finalout*finalout;//  Gain calculated with simple square and add  
          }
          gain[outer_loop]=sum;         //  Gain stored to test filter response
          printf("%f\n",sum);           //  Open Terminal I/O to view gain 
     }
}
                                   




   

⌨️ 快捷键说明

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