Digital Signal Processing Reference
In-Depth Information
// Ramptable.c Generates a ramp using a look-up table
#include "dsk6713_aic23.h" //codec-dsk support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#define table_size (int)0x400 //size of table=1024
short data_table[table_size]; //data table array
int i;
interrupt void c_int11()
//interrupt service routine
{
output_sample(data_table[i]);
//ramp value for each Ts
if (i < table_size-1) i++;
//if table size is reached
else i = 0;
//reinitialize counter
return;
//return from interrupt
}
main()
{
for(i=0; i < table_size; i++)
{
data_table[i] = 0x0;
//clear each buffer location
data_table[i] = i * 0x20;
//set to 0,32,64,96,..,32736
}
i = 0;
//reinit counter
comm_intr();
//init DSK, codec, McBSP
while (1);
//infinite loop
}
FIGURE 2.14. Ramp generation program using a lookup table ( ramptable.c ).
Example 2.9: Ramp Generation without a Lookup Table ( ramp )
Example 2.8 is based on loading a table with a set of values, then outputting each
value in the table every sample period, wrapping around when the end of the table
is reached. Figure 2.15 shows a listing of the program ramp.c , which generates a
ramp using an alternative approach to Example 2.8. Starting with an initial output
value of 0, the output value is incremented by 0x20 every sample period T s .The
values sent for output are then 0, 32, 64, 96,...,32,736.
Build and run this project as ramp . Verify that a ramp with a negative slope and
an approximate peak value of 3 V is generated. To obtain a ramp with a positive
slope, change output to
output -= 0x20;
so that the output becomes 0,
-
32,
-
64,...,
-
32,736. Also change the if statement
to reinitialize output ,or
if
(output == -0x7FFF)
Search WWH ::




Custom Search