fixpoint_cascadetiir.c

来自「CHP 5 - Real-Time Digital Signal Process」· C语言 代码 · 共 42 行

C
42
字号
// 
//  Project: Exercise 5.24 implementation of fixed-point IIR filter in direct form-II - Chapter 5
//  File name: fixPoint_cascadeIIR.c   
//
//  Description: This is the fixed-point IIR filter in direct form I realization
//
//  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 "directIIR.h"

void cascadeIIR(short in, short (*w)[3], short *y, 
                short (*b)[3], short (*a)[3], short section)
{
  long  temp32;
  short k,temp16;

  temp16 = in;
  for(k=0; k<section; k++)     
  {
    temp32  = (long)w[k][1] * a[k][1];
    temp32 += (long)w[k][2] * a[k][2];
    temp32 >>= 14;
    w[k][0] = temp16 - (short)(temp32);
    temp32  = (long)w[k][0] * b[k][0];
    temp32 += (long)w[k][1] * b[k][1];
    temp32 += (long)w[k][2] * b[k][2];
    temp32 >>= 14;
    temp16  = (short)(temp32);
    w[k][2] = w[k][1];
    w[k][1] = w[k][0];
  }

  *y = temp16;               // Save the result 
}

⌨️ 快捷键说明

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