Site Index
   Support Home
   C6000 Home
   DaVinci EVM
   EVMDM6437
   EVM6424
   EVMDM642
   XEVM642
   DSKTCI6482
   EVMTCI6482
   DSK6455
   EVM6455
   EVM6418
   DSK6713
   DSK6416
   Ordering Info.
Google

C6000 Site
Support Site
Main Site

EVM6418 Tone Example

The tone example is a slightly more complicated program that directs the AIC23 codec to generate a 1KHz sine wave on the line and headphone outputs. Follow these instructions to load and run the tone example.

  1. Close and projects you were working with previously by selecting Project -> Close. You should also close any open files you have open in your workspace avoid confusion. Click on the X in the upper right hand corner of their windows to close them.

  2. Plug a pair of headphones or speakers into the EVM’s headphone jack

  3. Open the tone.pjt Code Composer project using Project -> Open and selecting tone.pjt. It is in the directory

       c:\CCStudio\boards\evm6418\examples\tone.
  4. Load the tone.out executable file. Select File -> Load Program. It will open a file browser dialog. Select the tone.out file in the tone\Debug directory in the file browser and hit "Open" to load the executable file.

  5. Select the Debug -> Run option under the Debug menu. You will hear a 1KHz tone.

  6. After 5 seconds the sound will stop.

When you are satisfied that the program is indeed running correctly, stop the program by selecting Debug -> Halt.

The array sinetable contains a pre-generated sine wave using signed 16-bit data that matches the AIC23. The data covers exactly one period and the amplitude matches the full range of the codec.

#define SINE_TABLE_SIZE   48

/* Pre-generated sine wave data, 16-bit signed samples */
Int16 sinetable[SINE_TABLE_SIZE] = {
  0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,
  0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x76ef,
  0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,
  0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,
  0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,
  0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c
};

The main loop of the code writes each data point in the sine wave table out to the codec using the AIC23 codec package of the BSL. Each write function sends a single 16 bit sample to the codec. In this case the same data is sent out twice, once to the left channel and once to the right channel. The codec is configured to accept data at a rate of 48,000 stereo samples per second. Since the sine table is 48 entries long, the resulting output wave will be a 1KHz sine wave with the same output on both the left and right channels.

// Generate a 1KHz sine wave for 5 seconds
for ( msec = 0 ; msec < 5000 ; msec++ )
{
  for ( sample = 0 ; sample < SINE_TABLE_SIZE ; sample++ )
  {
    /* Send a pair of stereo samples
     * left high & right low */
    while ( ! EVM6418_AIC23_write( hCodec, 
           (sinetable[sample]<<16) | sinetable[sample]));
  }
}

The McASP is used to transmit data to the codec at a much slower rate than the DSP can process data. It accepts data 32 bits at a time and shifts them out slowly one at a time. The write function returns a 1 if the write is completed successfully or a 0 if the serial channel is busy. The while() loop around the writes waits while the serial port is busy so program can be synchronized to the data rate of the codec.

The 32 bit data consists of two 16-bit samples, each corresponding to one of the two audio channels. The left data sits in the top half of the 32-bit word while the right data sits in the bottom half . Each sample is a signed 16-bit value.

The following two commands are used to initialize and shut down the codec and are found at the beginning and end of all programs that use BSL codec module. The EVM6418_openCodec() command returns a handle that is passed each of the other codec functions.

/* Start the codec */
hCodec = EVM6418_AIC23_openCodec( 0, &config, 
                EVM6418_AIC23_OUTPUT );

/* Close the codec */
EVM6418_AIC23_closeCodec( hCodec );
©Copyright 2002-2012 Spectrum Digital, Inc. All Rights Reserved.