c55cosinetest.c

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

C
47
字号
// 
//  Project: Experiment 3.6.5.3 Function Approximaiton - Chapter 3 
//  File name: c55CosineTest.c   
//
//  Description: This experiment program is implemented for testing the assembly
//               routine implementation of cosine function in the range of [0, PI/2]
//               using function: cos(x)=1-(1/2!)x^2+(1/4!)x^4-(1/6!)x^6
//
//  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
//

#define PI (double)3.1415926
#define UNITQ15  0x7FFF
#define UNITQ14  0x3FFF

extern short cosine(short T0);

void main(void)
{
  static double y[5];
  short  x[5],z[5];
	
  x[0] = (short)(0);                     // Q14 format input in rad
  x[1] = (short)(UNITQ14*PI/6.0);        // Q14 format input in rad
  x[2] = (short)(UNITQ14*PI/4.0);        // Q14 format input in rad
  x[3] = (short)(UNITQ14*PI/3.0);        // Q14 format input in rad
  x[4] = (short)(UNITQ14*PI/2.0);        // Q14 format input in rad
	
  z[0] = cosine(x[0]);                   // Assembly funciton calculation
  z[1] = cosine(x[1]);                   // Assembly funciton calculation
  z[2] = cosine(x[2]);                   // Assembly funciton calculation
  z[3] = cosine(x[3]);                   // Assembly funciton calculation
  z[4] = cosine(x[4]);                   // Assembly funciton calculation

  y[0] = (double)z[0]/UNITQ15;
  y[1] = (double)z[1]/UNITQ15;
  y[2] = (double)z[2]/UNITQ15;
  y[3] = (double)z[3]/UNITQ15;
  y[4] = (double)z[4]/UNITQ15;                       
}

⌨️ 快捷键说明

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