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

📄 blockfirtest.c

📁 CHP 4 - Real-Time Digital Signal Processing: Implementations and Applications, Second Edition by Sen
💻 C
字号:
// 
//  Project: Experiment 4.5.2 Assembly implementation of block FIR filter - Chapter 4
//  File name: blockFirTest.c   
//
//  Description: This is the test program for the 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 <stdlib.h>
#include <stdio.h>

#include "blockFir.h"

// Define DSP system memory map  
#pragma DATA_SECTION(blockFirCoef, "expdata0:fir");
#pragma DATA_SECTION(w, ".bss:fir");

short blockFirCoef[NUM_TAPS]={
   #include "blockFirCoef.h"
};

short w[NUM_TAPS];
short x[NUM_DATA],  // Input data array
      y[NUM_DATA];  // Output data array

void main()
{
  FILE  *fpIn,*fpOut;
  short i,k,
  index;        // Delay line index
  char  temp[NUM_DATA*2];

  fpIn = fopen("..\\data\\input.pcm", "rb");
  fpOut = fopen("..\\data\\output.pcm", "wb");

  if (fpIn == NULL)
  {
    printf("Can't open input file\n");
    exit(0);
  }
	
  // Initialize for filtering process
  for (i=0; i<NUM_TAPS; i++)
  {
    w[i] = 0;
  }
  index = 0;

  // Begin filtering the data
  while (fread(temp, sizeof(char), NUM_DATA*2, fpIn) == (NUM_DATA*2))
  {
    for (k=0, i=0; i<NUM_DATA; i++)
    {
      x[i] = (temp[k]&0xFF)|(temp[k+1]<<8);
	k += 2;
    }
    // Filter the input data x and save the output data y
    blockFir(x, NUM_DATA, 
             blockFirCoef, NUM_TAPS, 
             y, 
             w, &index);

    for (k=0, i=0; i<NUM_DATA; i++)
    {
      temp[k++] = (y[i]&0xFF);
      temp[k++] = (y[i]>>8)&0xFF;
    }

    fwrite(temp, sizeof(char), NUM_DATA*2, fpOut);
  }
  
  fclose(fpIn);
  fclose(fpOut);
}

⌨️ 快捷键说明

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