sinegen_table.c

来自「dsp原理及其C编程开发技术相关代码 希望对做DSP编程朋友有所帮助」· C语言 代码 · 共 27 行

C
27
字号
//Sinegen_table.c Generates a sinusoid for a look-up table 
 
#include <math.h>
#define table_size (short)10	 //set table size
short sine_table[table_size];	 //sine table array
short i;

interrupt void c_int11()	 //interrupt service routine
{
 output_sample(sine_table[i]); //output each sine value
 if (i < table_size - 1) ++i;  //incr index until end of table
    else i = 0;			 //reinit index if end of table
 return;				 //return from interrupt
}
 
void main()
{  
float pi=3.14159;

for(i = 0; i < table_size; i++)
  sine_table[i]=10000*sin(2.0*pi*i/table_size); //scaled values

i = 0;
comm_intr();                   //init DSK, codec, McBSP
while(1);                      //infinite loop
}

⌨️ 快捷键说明

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