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 Evm_App Example

The EVM_App example digitally processes audio data from the line input on the AIC23 codec and plays the result on the headphone and line output. It uses the McBSP and EDMA to efficiently handle the data transfer without intervention from the DSP. The example resides in:

   c:\CCStudio\boards\evm6418\examples\evm_app.

The DMA driven audio implemented by the audio example is highly optimized and representative of what might be used in production code. It is a good base to use for your own audio code.

If no DIP switches are pressed, the example simply passes the audio from the line-in to the audio outputs. LEDs #2 and #3 toggle as the data is being transferred. If the DIP switches are depressed, the following things occur:

Dip Switch# Function
0 Blink LED #0 once per second.
1 Add a dummy load that takes 20-25% of the processor time.

The functions are independently controlled so you can, for example, blink LED #0 and add the dummy load at the same time

Follow these instructions to load and run the EVM_App 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. Also connect an audio source like a CD player to the line input of the EVM6418 using a standard 1/8" male to male audio cable.

  3. Make sure all your DIP switches are in the up position.

  4. Open the EVM_App.pjt Code Composer project using Project -> Open and selecting evm_app.pjt. It is in the directory

       c:\CCStudio\boards\evm6418\examples\evm_app.
  5. Enable RTDX by selecting Tools -> RTDX -> Configuration Control and checking the Enable RTDX checkbox. RDTX is a communication protocol that allows your program to communicate with Code Composer through the JTAG emulation connection. The settings should be set for non-continuous mode with a buffer size of 1024. You can close this window by right clicking on the gray window area and selecting close. For more information about RTDX please see the RTDX section in the main Code Composer help.

  6. Enable the CPU load plugin by selecting DSP/BIOS -> CPU Load Graph. The load graph will appear at the bottom of your Code Composer window. You can make it a movable window by right-clicking on it and selecting Float In Main Window.

  7. Load the EVM_App.out executable file. Select File -> Load Program. It will open a file browser dialog. Select the EVM_App.out file in the EVM_App\Debug directory in the file browser and hit "Open" to load the executable file.

  8. Select the Debug -> Run option under the Debug menu. You will hear your audio source playing through the EVM6418 on the headphone output. Adjust the volume of your audio source until you get to a comfortable listening level.

    You will see LEDs #2 and #3 blinking. They toggle every time a ping or pong buffer is received. You will also see a display on the CPU load graph indicating what percentage of the total cycles are spent doing real work. It should be well under 10%.

  9. Press DIP switch #0. This will instruct the periodic thread blinkLED() to blink LED #0.

  10. Press DIP switch #1. This will enable a 20-25% dummy CPU load that represents other computation the DSP may be doing. You will see the CPU load go up by a substantial amount.

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

EVM_App Program Flow
When the program is run, the individual DSP/BIOS modules are initialized as configured in EVM_App.cdb with the DSP/BIOS configuration tool. The main() function is then called as the main user thread. In this example main() performs application initialization and starts the EDMA data transfers. When main exits, control passes back entirely to DSP/BIOS which services any interrupts or threads on an as-needed basis. When there is no work to be done and idle thread is run. EDMA interrupts will pre-empt the idle thread.

The edmaHwi() interrupt service routine is called when a buffer has been filled. It contains a state variable named pingOrPong that indicates whether the buffer is a PING or PONG buffer. edmaHwi() switches the buffer state to the opposite buffer and calls the SWI thread processBuffer() to process the audio data. processBuffer() is responsible for manually transferring receive data to the transmit buffers. It can be replaced with code that processes the data rather than copying it.

Two periodic threads (blinkLED() and load()) run asynchronously with the audio processing as a demonstration of DSP/BIOS multitasking. blinkLED() runs every 500ms and checks DIP switch #0. If it is depressed, the thread will toggle the LED. load() runs every 10ms and starts by checking DIP switch #1. If it is depressed, load() will run for a small amount of time simulating a workload occupying 20-25% of the processor time.

EVM_App Data Transfer
Audio data is transferred back and forth from the codec through McBSP1, a bidirectional serial port. The EDMA is configured to take every 16-bit signed audio sample arriving on McBSP1 and store it in a buffer in memory until it can be processed. Once it has been processed, it is sent back out through McBSP2 to the codec for output. One EDMA channel is used to transmit data to the codec while another is used to receive data from the codec. A full description of the codec interface can be found in the Codec Overview.

The example uses EDMA to relieve the DSP from the duty of data transfer. The EDMA controller takes incoming audio data directly from McBSP1 and places it in a memory buffer. It also takes data from a memory buffer and sends it to McBSP1 to generate the audio output. Separate EDMA channels are used to transmit and receive audio data.

Two special features to implement an especially robust and efficient data transfer infrastructure:

  1. Ping-pong buffering

  2. Linked EDMA transfers

Data Transfer Overview
The following figure illustrates the flow of audio data through the program:

Digital audio data is received from the codec on McBSP1. The audio data is a series of 16-bit signed integers representing the amplitude of the input waveform at a particular point in time. Since the AIC23 is a stereo codec, the audio input consists of both left and right audio channels. Data is received in a frame consisting of two elements, one 16-bit sample from the left channel followed by one 16-bit sample from the right channel. Frames are received at a rate of 48KHz, the EVM’s default sample rate.

Ping-Pong Transfers
At the highest level, the EDMA controller reads audio data from the McBSP and places it in a buffer in memory. On the data receive side there are two logical buffers, receive PING and receive PONG. When the first data comes in it is placed in the PING buffer. When it is full, new data is redirected to the PONG buffer and the DSP is free to process the PING data without fear of it being overwritten. When the PONG buffer fills up, the configuration is reversed. The ping-ponging data transfer continues indefinitely with one buffer always hosting the active transfer and one remaining stable for the DSP to operate on. If only one buffer is used, the DSP must process all of the data between the instant the buffer fills up and the next audio sample arrives. When ping-pong buffers are used, the DSP can take as long as the time it takes to fill an entire buffer to process the data, making it much easier to meet a real-time schedule.

Separate input and output buffers are used to decouple the receive side from the transmit side while data is being processed. The output buffers are also of the ping-pong variety so there are a total of four logical buffers, receive PING, receive PONG, transmit PING and transmit PONG.

  Int16 gBufferRcvPing[BUFFSIZE];  // Transmit PING buffer
  Int16 gBufferRcvPing[BUFFSIZE];  // Transmit PONG buffer
  Int16 gBufferRcvPong[BUFFSIZE];  // Receive PING buffer
  Int16 gBufferRcvPong[BUFFSIZE];  // Receive PONG buffer

EDMA Linked Transfers
The final special data transfer feature is called linked transfers. When the EDMA finishes with the PING side and needs to switch to the PONG side, the source and destination pointers need to be changed to point at the new buffer. When linked transfers are used, the new address can stored in a link configuration structure and automatically by loaded by the EDMA controller when the current transfer is complete. The reconfiguration can also be handled by the DSP in software interrupt service routine but using linked transfers removes the scheduling requirement that the software finish before the next sample is received to get uninterrupted audio.

©Copyright 2002-2012 Spectrum Digital, Inc. All Rights Reserved.