示例#1
0
void main()
{
	//initialize intermediary values to zero
	for(n = 0; n < 11; n++)
	{
		w[n] = 0;
	}

	DSK6713_init();		// Initialize the board support library, must be called first
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_16KHZ);

	// interrupt setup
	IRQ_globalDisable();			// Globally disables interrupts
	IRQ_nmiEnable();				// Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	while(1)						// main loop - do nothing but wait for interrupts
	{
	}
}
示例#2
0
int main(void) {

	/* Initialize the CSL and the CPLD */
	CSL_init();
	DSK6713_init();
	DSK6713_LED_init();

	/* Turn on one LED so we can see it executed at least the main function */
	DSK6713_LED_on(0);

	/* Initialize the DIP switches to be able to read them */
	DSK6713_DIP_init();


	/* Configure the codec according to the definitions in config_AIC23.c
	 * via the McBSP0 interface
	 */
	conf_AIC23();

	/* Configure the McBSP to transfer the data from and to the codec */
	conf_MCBSP();

	/* Start the MCBSP */
	start_MCBSP();

	/* Configure EDMA */
	conf_EDMA();

	/* Time to initialize the buffer and zerofill it */
	for(i = 0; i < 10; i++) FIFO_I[i] = 0;
	for(i = 0; i < 10; i++) FIFO_Q[i] = 0;


	/* Config Interrupts */
	IRQ_enable(IRQ_EVT_EDMAINT);
	IRQ_map(IRQ_EVT_EDMAINT, 8);
	IRQ_globalEnable();

	/* Enable the EDMA channels */
	EDMA_enableChannel(hEDMATrx);


	/******************************************************/
	/* We should be done here by now. The McBSP generates an
	 * Interrupt (called "event" in this case) each time
	 * there's a new word ready to be written or ready to
	 * be transferred from the serial port to the
	 * input buffer. We use it for the golden wire config
	 * and will disable the input when we throw in the
	 * QPSK modulation algorithm as it is not needed by then.
	 */
	/******************************************************/

	/* End main - RTOS takes over */
}
示例#3
0
void init_DSK(void)
{
	// set up the C6713, the AIC and initialize the CSL libraries
	DSK6713_init();        // TI routine to initialize the 6713 DSK board
	CSL_init();            // TI routine to initialize CSL libraries when not using BIOS

	// Set up AIC through control port connected to MCBSP0
	aic_control = DSK6713_AIC23_openCodec(0, &aicsettings); // pointer to aic control serial port (0)
	DSK6713_AIC23_setFreq(aic_control, samprate);            // set the aic sample rate

}
示例#4
0
文件: main.c 项目: mewashin/SPH
/**
 * main method
 * contains main run loop
 */
int main() {
	//prototype for linear assembly convolution function
	extern int convolve_as_func(int x[], int w[], int x_idx, int w_length);
	
	DSK6713_init();
	hCodec = DSK6713_AIC23_openCodec(0,&config);
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_8KHZ);

	// enable interrupts
	IRQ_globalEnable();
	IRQ_enable(IRQ_EVT_RINT1);
	IRQ_enable(IRQ_EVT_XINT1);
	
	reset();	// init the input buffer to zeros

	// get the time to make a clock() funciton call; used only for profiling
	/*
	start = clock();
	end = clock();
	diff = end - start;
	*/

	// the first write is needed to trigger the transmit interrupt
	while(!DSK6713_AIC23_write(hCodec, 0));
	in_channel_flag = 1;
	out_channel_flag = 1;

	while(1) {
		if(input_ready) {
			//process sample when input is ready
			sig_error = process_sample(in_left, in_right);
			input_ready = 0;
		}

		// set output when ready
		if(output_ready) {
			out_left = in_left;
			out_right = sig_error;
			output_ready = 0;
		}
	};
	

	/* The program will never exit this loop */
	/* However, if you _do_ exit the loop (say, using a break
	 * statement) close the D/A converter properly */
	DSK6713_AIC23_closeCodec(hCodec);
	exit();
}
示例#5
0
/******************************* init_hardware() ************************************/
void init_hardware()
{
    // Initialize the board support library, must be called first 
    DSK6713_init();
    
    // Start the codec using the settings defined above in config 
    H_Codec = DSK6713_AIC23_openCodec(0, &Config);

	/* Defines number of bits in word used by MSBSP for communications with AIC23
	 NOTE: this must match the bit resolution set in in the AIC23 */
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);
	
	/* Set the sampling frequency of the audio port. Must only be set to a supported 
	   frequency (8000/16000/24000/32000/44100/48000/96000) */
	
	DSK6713_AIC23_setFreq(H_Codec, get_sampling_handle(&sampling_freq));

}
示例#6
0
void main()
{
	DSK6713_init();		// Initialize the board support library, must be called first
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

    //convert coefficients to Q15 format
    short i,j;
    for(i = 0; i < 33; i++)
    {
    	w[i] = 0;
    }

    for(i = 0; i < 11; i++)
    {
    	for(j = 0; j < 3; j++)
    	{
    		NUM_s[i][j] = NUM[i][j] << 5;
    		DEN_s[i][j] = DEN[i][j] << 5;
    	}
    }

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_16KHZ);

	// interrupt setup
	IRQ_globalDisable();			// Globally disables interrupts
	IRQ_nmiEnable();				// Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	while(1)						// main loop - do nothing but wait for interrupts
	{
	}
}
示例#7
0
// dsp-peripheral initialization
void c6713_dsk_init() {

	// call BSL to init DSK-EMIF,PLL)
	DSK6713_init();

	// handle(pointer) to codec
	hAIC23_handle=DSK6713_AIC23_openCodec(0, &config);

	// set sample rate
	DSK6713_AIC23_setFreq(hAIC23_handle, fs);

	// choose mic or line in
	DSK6713_AIC23_rset(hAIC23_handle, 0x0004, inputsource);

	// interface 32 bits toAIC23
	MCBSP_config(DSK6713_AIC23_DATAHANDLE,&AIC23CfgData);

	// start data channel again
	MCBSP_start(DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START | MCBSP_RCV_START |
			MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC, 220);
}
void main(){
    DSK6713_AIC23_CodecHandle hCodec;

	int i;

    /* Initialize the board support library, must be called first */
    DSK6713_init();

    /* Start the codec, set sample rate to 8kHz */
    hCodec = DSK6713_AIC23_openCodec(0, &config);
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_8KHZ);

	/* Output all the notes 2 times */
	for(i=0;i<2;i++){
		//#include "sequence.h"
	}
	//play Deck the Halls, based on the notes the DSK identified
	#include "sequence_deck.h"

    /* Close the codec */
    DSK6713_AIC23_closeCodec(hCodec);
}
/********************************** init_hardware() **********************************/  
void init_hardware()
{
    // Initialize the board support library, must be called first 
    DSK6713_init();
    
    // Start the AIC23 codec using the settings defined above in config 
    H_Codec = DSK6713_AIC23_openCodec(0, &Config);

	/* Function below sets the number of bits in word used by MSBSP (serial port) for 
	receives from AIC23 (audio port). We are using a 32 bit packet containing two 
	16 bit numbers hence 32BIT is set for  receive */
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);	

	/* Configures interrupt to activate on each consecutive available 32 bits 
	from Audio port hence an interrupt is generated for each L & R sample pair */	
	MCBSP_FSETS(SPCR1, RINTM, FRM);

	/* These commands do the same thing as above but applied to data transfers to  
	the audio port */
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);	
	MCBSP_FSETS(SPCR1, XINTM, FRM);	
}
示例#10
0
文件: Exp2.c 项目: jacyzon/DSP-LAB
/*
 *  main() - The main user task.  Performs application initialization and
 *           starts the data transfer.
 */
void main()
{
    /* Initialize Board Support Library */
    DSK6713_init();

    /* Initialize LEDs and DIP switches */
    DSK6713_LED_init();
    DSK6713_DIP_init();

    /* Clear buffers */
    memset((void *)gBufferXmtPing, 0, BUFFSIZE * 4 * 2);

    AIC23_setParams(&config);  // Configure the codec

    initMcbsp();               // Initialize McBSP1 for audio transfers

    IRQ_globalDisable();       // Disable global interrupts during setup

    initEdma();                // Initialize the EDMA controller

    initIrq();                 // Initialize interrupts

    IRQ_globalEnable();        // Re-enable global interrupts
}
示例#11
0
void main()
{


	// initialize the save buffers
	for(j = 0; j < 2; j++){
		for (i=0;i<SAVES;i++) {
			cde_save[i] = 0;
			pcf_save[i] = 0;
			clockoffset_save[i] = 0.0;
			fde_save[i] = 0.0;
			imax_save[i] = 0;
			recbuf_start_clock_save[i] = 0;
			ppm_estimate_save[i] = 0.0;
			ytilde_save[i] = 0.0;
			state_prediction[j][i] = 0.0;
			state_estimate[j][i] = 0.0;
		}
	}

	// set up the fractionally shifted buffers
	for(k = 0; k < FER; k++){
		fractionalShift = ((double) k )/((double) FER); // number of samples to shift
		for (i=-N;i<=N;i++){
			x = ((double) i - fractionalShift)*BW;
			if (x==0.0) {
				y = 32767.0;
			}
			else
			{
				t = ((double) i - fractionalShift)*CBW;
				y = 32767.0*cos(2*PI*t)*sin(PI*x)/(PI*x); // double
			}
			j = i;
			if (j<0) {
				j += L; // wrap
			}
			allMyDelayedWaveforms[k][j] = (short) y;
		}
	}

	// set up the cosine and sin matched filters for searching
	// also initialize searching buffer
	for (i=0;i<M;i++){
		t = i*CBW;				// time
		y = cos(2*PI*t);		// cosine matched filter (double)
		mfc[i] = (float) y;		// cast and store
		y = sin(2*PI*t);		// sine matched filter (double)
		mfs[i] = (float) y;     // cast and store
		buf[i] = 0;             // clear searching buffer
	}

	// initialize clock buffers
	for (i=0;i<L;i++) {
		clockbuf[i] = 0;
		clockbuf_shifted[0][i] = 0;
		clockbuf_shifted[1][i] = 0;
	}

	// initialize sinc pulse buffer
	for (i=0;i<LL;i++)
		sincpulsebuf[i] = 0;

	// set up clock buffer and sinc pulse buffer
	// to play modulated sinc centered at zero
	for (i=-N;i<=N;i++){
		x = i*BW;
		if (i!=0) {
			t = i*CBW;
			y = 32767.0*cos(2*PI*t)*sin(PI*x)/(PI*x); // double
		}
		else {
			y = 32767.0;
		}
		j = i;
		if (j<0) {
			j += L; // wrap
		}
		clockbuf[j] = (short) y;
		j = i;
		if (j<0) {
			j += LL; // wrap
		}
		sincpulsebuf[j] = (short) y;
	}

	// set up inphase and quadrature sinc pulses for coarse and fine delay estimators
	j = 0;
	for (i=-N;i<=N;i++){
		x = i*BW;
		if (i!=0) {
			t = i*CBW;
			si[j] = (float) (cos(2*PI*t)*sin(PI*x)/(PI*x));
			sq[j] = (float) (sin(2*PI*t)*sin(PI*x)/(PI*x));
		}
		else {
			si[j] = 1.0;
			sq[j] = 0.0;
		}
		j++;
	}

	DSK6713_init();		// Initialize the board support library, must be called first
	DSK6713_LED_init(); // initialize LEDs
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_8KHZ);

	// interrupt setup
	IRQ_globalDisable();			// Globally disables interrupts
	IRQ_nmiEnable();				// Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	DSK6713_LED_toggle(3);

	while(1)						// main loop
	{
		if ((state==2)&&(delay_est_done==0)){  // TIME TO COMPUTE DELAY ESTIMATES

			DSK6713_LED_toggle(1);	// toggle LED here for diagnostics

			/*****************
			 * 				 *
			 * ESTIMATION    *
			 * 				 *
			 ****************/

			// compute coarse delay estimate
			zmax = 0.0;				// maximum
			imax = 0;				// index of maximum
			for (i=0;i<(2*M-1);i++){  // lag index
				z = 0;
				for (j=0;j<(2*N+1);j++) {
					z+= si[j]*recbuf[i+j];  // correlation at lag i
				}
				if (abs(z)>zmax) {
					zmax = abs(z);  // store maximum
					imax = i;       // store index of maximum
				}
			}
			cde = recbuf_start_clock + imax + N;  // coarse delay estimate (DRB: +N here because si is already shifted by N)
			// cde  is the number of samples elapsed since we launched the S->M sinc pulse

		    // compute fine delay estimate
			zi = 0.0;  // in phase
			zq = 0.0;  // quadrature
			for (j=0;j<(2*N+1);j++) {
				zi+= si[j]*recbuf[imax+j];  // correlation at lag imax
				zq+= sq[j]*recbuf[imax+j];  // correlation at lag imax
			}
			pcf = atan2(zq,zi)*(2*INVPI); // assumes wc = pi/2
			fde = (float) cde + pcf;

			// compute actual clock offset
			// the value computed here is always non-negative and
			// represents the number of samples the master clock is ahead of the slave clock
			// (or the number of samples the slave clock is behind the master clock)
			// S->M sinc pulse was launched at time 0
			// M->S sinc pulse was received at time fde (should be positive)
			// to synchronize, we want slave clock ticks to appear at fde/2 + k*L for k=0,1,....
			clockoffset = fde*0.5;

			// testing/debugging
			imax_save[save_index] = imax;
			recbuf_start_clock_save[save_index] = recbuf_start_clock;
			cde_save[save_index] = cde;
			pcf_save[save_index] = pcf;
			fde_save[save_index] = fde;
			clockoffset_save[save_index] = clockoffset;


			//If first time running
			if(!hasSaved && save_index == 0){
			   state_estimate[0][0] = clockoffset* TS;
			   state_estimate[1][0] = 0;
			   state_prediction[0][1] = clockoffset * TS;
			   state_prediction[1][1] = 0;
			}

			else
			{   // save_index > 0
			    ytilde = clockoffset * TS - state_prediction[0][save_index];  // innovation (difference between current observation and prediction)


			    state_estimate[0][save_index] = state_prediction[0][save_index] + ((double) K1)*ytilde;  // filtered clock offset estimate
			    state_estimate[1][save_index] = state_prediction[1][save_index] + ((double)K2)*ytilde;  // filtered frequency offset estimate

			    //Determine if a glitch has happened


			    if (save_index+1<SAVES) {
			        // generate predictions for next observation (make sure multiplication by LL doesn't cause datatype problems)
			        state_prediction[0][save_index+1] = state_estimate[0][save_index] +  state_estimate[1][save_index] * (double)T0;//* LL;
			        state_prediction[1][save_index+1] = state_estimate[1][save_index];
			    }
			    else if(save_index + 1 == SAVES){
			    	state_prediction[0][0] = state_estimate[0][save_index] + state_estimate[1][save_index]* (double)T0;//* LL;
			    	state_prediction[1][0] = state_prediction[1][save_index];
			    }
			}

			//Calculate the rate offset
			if(!hasSaved && save_index < 1){
				if(save_index == 0)
					rateoffset_estimate = 0;
				else
					rateoffset_estimate = TS * (clockoffset_save[save_index] - clockoffset_save[save_index - 1]);
			}

			//Otherwise, use kalman filter
			else{
				rateoffset_estimate = state_prediction[0][save_index] - state_estimate[0][save_index];

			}

			//

			if(clockoffset_save[save_index] > L && clockoffset_save[save_index - 1] < L)
				adjustedclockoffset = clockoffset_save[save_index] + 5 * L * rateoffset_estimate;
			else if(clockoffset_save[save_index] > L && clockoffset_save[save_index - 1] < L)
				adjustedclockoffset = clockoffset_save[save_index] + 3 * L *rateoffset_estimate;
			else
				adjustedclockoffset = clockoffset_save[save_index] + 4 * L * rateoffset_estimate;
			////////


			j = (short) adjustedclockoffset; // casting from float to short just truncates, e.g., 3.99 becomes 3
			fractionalShift = adjustedclockoffset - (double) j; // fractionalShift >= 0 and < 1 tells us how much of a sample is left
			k = (short) (fractionalShift * (double) FER + 0.5);  // this now rounds and givse results on 0,...,FER
			if (k==FER) {  // we rounded up to the next whole sample
				k = 0;
				j++;
			}
			for (i=0;i<L;i++) {
				ell = j+i;

				while (ell>=L) {
					ell = ell-L;
				}

				if (current_clockbuf==0) {
					clockbuf_shifted[1][ell] = allMyDelayedWaveforms[k][i];  // write other buffer
				}
				else {
					clockbuf_shifted[0][ell] = allMyDelayedWaveforms[k][i];  // write other buffer
				}

			}

			// when can we swap buffers?
			buffer_swap_index = j+L/2;  // midpoint of the silent part (I think)
			while (buffer_swap_index>=L)
				buffer_swap_index = buffer_swap_index-L;

			// tell the ISR the calculations are done
			delay_est_done = 1;

			// update save index
			save_index++;
			if (save_index>=SAVES)  // wrap
				{
				save_index = 0;
				hasSaved = 1;
				}

			DSK6713_LED_toggle(1);	// toggle LED here for diagnostics

		}
		else if (buffer_just_swapped==1) {
			// this code computes the next buffer and attempts to corect for the frequency offset
			buffer_just_swapped = 0;
			// copy appropriate fractionally shifted clock buffer to shifted clock buffer
			adjustedclockoffset = adjustedclockoffset + ((double) L)*one_over_beta;  // adjust latency of next pulse
			while (adjustedclockoffset>((double) L))
				adjustedclockoffset = adjustedclockoffset - (double) L;
			j = (short) adjustedclockoffset; // casting from float to short just truncates, e.g., 3.99 becomes 3
			fractionalShift = adjustedclockoffset - (double) j; // fractionalShift >= 0 and < 1 tells us how much of a sample is left
			k = (short) (fractionalShift * (double) FER);  // this also truncates and should give result on 0,...,FER-1
			for (i=0;i<L;i++) {
				ell = j+i;
				if (ell>=L) {
					ell = ell-L;
				}
				if (current_clockbuf==0) {
					clockbuf_shifted[1][ell] = allMyDelayedWaveforms[k][i];  // write other buffer
				}
				else {
					clockbuf_shifted[0][ell] = allMyDelayedWaveforms[k][i];  // write other buffer
				}

			}
		} // if ((state==2)&&(delay_est_done==0))
	}  // while(1)
}  // void main
示例#12
0
void main()
{
	DSK6713_init();		// Initialize the board support library, must be called first
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_8KHZ);

	//initialize buffers to zero
	init();

	// interrupt setup
	IRQ_globalDisable();			// Globally disables interrupts
	IRQ_nmiEnable();				// Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	//temporary variable for real-imag swapping for ifft, placed here for convenience
	float temp = 0;

	while(1)						// main loop - do nothing but wait for interrupts
	{
		if(pingFlag == 1){
			for(n = 0; n < FFT_LENGTH; n++){
				if(n < (ORDER - 1)){
					pingU[n] = Z[n];
				}
				else{
					pingU[n] = PING[n - (ORDER - 1)];
				}
			}
//			cfftr2_dit(pingU,w,FFT_LENGTH); //TI floating-pt complex FFT
//			bitrev(pingU,ix,FFT_LENGTH); //freq scrambled->bit-reverse X

			for(n = 0; n < FFT_LENGTH; n++){
//				V[n] = cmplxMult(h[n],pingU[n]);

				V[n] = pingU[n];

				//swap real and imaginary for ifft, remember to uncomment temp as well
//				temp = V[n].re;
//				V[n].re = V[n].im;
//				V[n].im = temp;
			}

//			cfftr2_dit(V,w,FFT_LENGTH) ; //TI floating-pt complex ifft
//			bitrev(V,ix,FFT_LENGTH); //freq scrambled->bit-reverse X

			for(n = ORDER - 1; n < FFT_LENGTH; n++)
			{
				outputPING[n] = V[n].re * 32768;
			}

			for(n = (FFT_LENGTH - (ORDER - 1)) - (ORDER -1); n < FFT_LENGTH - (ORDER - 1); n++)
			{
				Z[n] = PING[n];
			}
			lflag = 1;
		}
		if(pongFlag == 1){
			for(n = 0; n < FFT_LENGTH; n++){
				if(n < (ORDER - 1)){
					pongU[n] = Z[n];
				}
				else{
					pongU[n] = PONG[n - (ORDER - 1)];
				}
			}

//			cfftr2_dit(pongU,w,FFT_LENGTH) ; //TI floating-pt complex FFT
//			bitrev(pongU,ix,FFT_LENGTH); //freq scrambled->bit-reverse X

			for(n = 0; n < FFT_LENGTH; n++){
//				V[n] = cmplxMult(h[n],pongU[n]);

				V[n] = pongU[n];

//				swap real and imaginary for ifft, remember to uncomment temp as well
//				temp = V[n].re;
//				V[n].re = V[n].im;
//				V[n].im = temp;
			}
//			cfftr2_dit(V,w,FFT_LENGTH) ; //TI floating-pt complex ifft
//			bitrev(V,ix,FFT_LENGTH); //freq scrambled->bit-reverse X

			for(n = ORDER - 1; n < FFT_LENGTH; n++)
			{
				outputPONG[n] = V[n].re * 32768;
			}

			for(n = (FFT_LENGTH - (ORDER - 1)) - (ORDER -1); n < FFT_LENGTH - (ORDER - 1); n++)
			{
				Z[n] = PONG[n];
			}
			lflag = 1;
		}
	}
}
void main()
{

	// set up the cosine and sin matched filters for searching
	// also initialize searching buffer
	for (i=0;i<M;i++){
		t = i*0.25;				// time
		y = cos(2*PI*t);		// cosine matched filter (double)
		mfc[i] = (float) y;		// cast and store
		y = sin(2*PI*t);		// sine matched filter (double)
		mfs[i] = (float) y;     // cast and store
		buf[i] = 0.0;             // clear searching buffer
		fbuf[i] = 0.0;
	}

	// initialize input buffer
	for (i=0;i<BL;i++)
		inbuf[i] = 0.0;

	// initialize clock buffer
	for (i=0;i<L;i++)
		clockbuf[i] = 0;

	// set up clock buffer to play modulated sinc centered at zero
	for (i=-N;i<=N;i++){
		x = i*BW;
		if (i!=0) {
			t = i*0.25;
			y = ((double) CLOCKAMPLITUDE)*cos(CARRIERKHZ*PI*t)*sin(PI*x)/(PI*x); // double
		}
		else {
			y = ((double) CLOCKAMPLITUDE);
		}
		j = i;
		if (j<0) {
			j += L; // wrap
		}
		clockbuf[j] = (short) y;
	}



	DSK6713_init();		// Initialize the board support library, must be called first
	DSK6713_LED_init(); // initialize LEDs
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_16KHZ);

	// interrupt setup
	IRQ_globalDisable();			// Globally disables interrupts
	IRQ_nmiEnable();				// Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	while(1)						// main loop
	{
	}
}