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

📄 fixedpointblockfir.c

📁 CHP 4 - Real-Time Digital Signal Processing: Implementations and Applications, Second Edition by Sen
💻 C
字号:
// 
//  Project: Experiment 4.5.1 Fixed-point implementation of block FIR filter - Chapter 4
//  File name: fixedPointFir.c   
//
//  Description: This is the fixed-point implementation of a block FIR filter
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//
//

#include "fixedPointFir.h"

// Define DSP system memory map  
#pragma CODE_SECTION(fixedPointBlockFir, ".text:fir");

void fixedPointBlockFir(short *x, short blkSize, 
						short *h, short order, 
						short *y, 
						short *w, short *index)
{
  short i,j,k;
  long sum;
  short *c;

  k = *index;
  for (j=0; j<blkSize; j++)           // Block processing
  {
    w[k] = *x++;                      // Get the current data to delay line
    c = h;
    for (sum=0, i=0; i<order; i++)    // FIR filter processing
    {
      sum += *c++ * (long)w[k++];
      if (k == NUM_TAPS)              // Simulate circular buffer
      {
        k = 0;
      }
    }    
    sum += 0x4000;                    // Rounding
    *y++ = (short)(sum>>15);          // Save filter output

    if (k-- <=0)                      // Update index for next time
    {
      k = NUM_TAPS-1;
    }
  }
  *index = k;                         // Update circular buffer index
}

⌨️ 快捷键说明

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