Digital Signal Processing Reference
In-Depth Information
//sine1500.h header file
short sin1500[128]=
{0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924,
0, 924, 707, -383, -1000, -383, 707, 924, 0, -924, -707,
383, 1000, 383, -707, -924};
Square wave generation using look-up table
//Squarewave.c Generates a square wave using a look-up
table
#define table_size (int)0x100 //size of table = 256
int data_table[table_size]; //data table array
int i;
interrupt void c_int11() //interrupt service routine
{
output_sample(data_table[i]); //output value each Ts
if (i < table_size) ++i; //if table size is reached
else i = 0; //reinitialize counter
return; //return from interrupt
}
main()
{
for(i=0; i<table_size/2; i++) //set 1st half of buffer
data_table[i] = 0x7FFF; //with max value (2^15)-1
for(i=table_size/2; i<table_size; i++)//set 2nd half of
buffer
data_table[i] = -0x8000; //with -(2^15)
 
Search WWH ::




Custom Search