Hi all
I am trying to generate a square wave on TIDSKC6713 (CCS) by modifying
a code from Chassaing book (chapter 2). I want to generate the square
wave with variable frequency fo upto 40kHz (by using 96kHz sampling
frequency). I am using a buffer of 128 values with half for positive
and half for negative amplitudes. I have used two slider GEL; one for
variable gain and other for variable frequency. With gain I could get
from 50mVpp to 2.8Vpp which seems OK to me but with frequency from
750Hz to 8kHz the output is square (with some ripples) but above that
the output is not square any more and starts modifying itself to the
shape of sinusoidal waveform.
I have copied the modified code. It would be much appreciated if some one could help me in this regard please.....
Many Thanks
#include "dsk6713_aic23.h" //codec-DSK interface support
Uint32 fs=DSK6713_AIC23_FREQ_96KHZ; //set sampling rate
#define table_size (int)0x80 //size of table=128
short data_table[table_size]; //data table array
int i,k;
int amplitude = 0x7fff;
short gain = 1;
int frequency = 1;
interrupt void c_int11() //interrupt service routine
{
output_sample(data_table[i] / gain); //output value each Ts
i += frequency;
i = i % table_size; //reinitialize counter
return; //return from interrupt
}
main()
{
for(i=0; i<table_size/2; i++) //set 1st half of buffer
data_table[i] = amplitude; //with max value (2^15)-1
for(i=table_size/2; i<table_size; i++) //set 2nd half of buffer
data_table[i] = -(amplitude + 1); //with -(2^15)
i = 0; //reinit counter
comm_intr(); //init DSK, codec, McBSP
while (1)
}