/*1 */ // This project uses support files generated by Rulph Chassaing
/*2 */ // Comm routines included in dsk6713_bsl.lib
/*3 */ #include <math.h>
/*4 */ #include "dsk6713_aic23.h"
/*5 */ #define PI 3.14159265359                // define the constant PI 
/*6 */ short sample_period=12;                 // sinusoid period in samples
/*7 */ short ctr;                              // loop counter
/*8 */ short phase[2];                         // theta in degrees (holds two values)
/*9 */ short out_value;                        // value sent to codec
/*10*/ float angle;                            // angle for cosine function
/*11*/ float wnts;                             // omega * n * ts - used for current angle     
/*12*/ Uint32 fs = DSK6713_AIC23_FREQ_24KHZ;   
/*13*/ 
/*14*/ interrupt void c_int11()                // interrupt service routine
/*15*/ {
/*16*/  int i;                                 // used in for loop 
/*17*/  // create interference pattern
/*18*/  // use amplitude 30000/N to prevent overflow in codec, where N=2
/*19*/  wnts = 2.0*PI*ctr/sample_period;       // current angle (w/out phase)
/*20*/  out_value=0;
/*21*/  for (i=0; i<2; i++) 
/*22*/  {
/*23*/    angle = wnts + phase[i]*PI/180;      // current angle (with phase)
/*24*/    out_value += (30000/2)*cos(angle);   // cos(w nts + theta_k) k in {1,2}
/*25*/  }
/*26*/  
/*27*/  //output interference pattern
/*28*/  output_left_sample(out_value);         // output each sine value
/*29*/  if (ctr < sample_period-1) ++ctr;      // increment counter (0 through 47)
/*30*/  else ctr = 0;                          // reset counter
/*31*/  return;                                // return from interrupt
/*32*/ }
/*33*/ 
/*34*/ void main()
/*35*/ {
/*36*/   phase[0]=0;                           // theta 1
/*37*/   phase[1]=45;                          // theta 2
/*38*/   ctr=0;                                // initialize counter   
/*39*/   comm_intr();                          // initialize DSK, codec, McBSP
/*40*/   while(1);                             // wait for an interrupt to occur
/*41*/ }
