NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
StarterWare Audio Application
DMA Buffer handling for Ping-Pong Operation
The StarterWare audio example application uses EDMA for audio data transmit and recieve operations. The audio data buffers associated with EDMA transmission are:
- 4 Transmit buffers - TX buffer-0, TX buffer-1, TX buffer-2, and a loop buffer.
- 3 Receive buffers - RX buffer-0, RX buffer-1, and RX buffer-2.
The EDMA paRAM sets are programmed to receive data in RX buffers and transmit data from TX buffers. When an RX buffer gets filled, the contents are be copied to the TX buffer, then it is transmitted. If no data is received, the EDMA paRAM sets for transmission are programmed to transmit from the loop buffer, which is a NULL buffer containing no valid audio data.
Initialization Of EDMA Parameters
Before the McASP transmit/receive state machines are brought out of reset, the EDMA paRAM sets are initialized. The main paRAM set for RX is paRAM set 0, and the main paRAM set for TX is paRAM set 1. After the main paRAM set expires, data transmission/reception continues on to linked paRAM sets. The linked paRAM sets do not expire since the EDMA copies the linked paRAM set to the main paRAM set and use it for data transfer. Hence, there is no need to update all the fields in a linked paRAM set after the associated transfer completion.
The RX paRAM set 0 is initialized to receive the first audio sample in the RX buffer-0. The transfer completion interrupt is not enabled for paRAM set 0. paRAM set 0 is linked to linked paRAM set 40. The paRAM set 40 resumes receiving data in RX Buffer 0. The paRAM set 40 is linked to paRAM set 41, which is initialized to receive data in RX Buffer 1. The paRAM set 41 is linked back to paRAM set 40. Hence the reception paRAM set is initialized as 0-->40-->41-->40. This linking does not change as the application executes.
All the TX paRAM sets are initialized to transmit from the loop buffer. The transfer completion interrupt is not enabled for paRAM set 1. paRAM set 1 is linked to paRAM set 42. paRAM set 42 and 43 are linked to themselves. Hence transmission paRAM set linking is initialized as 1-->42-->42, 43->43.
Releasing the McASP TX and RX state machines from reset
Once McASP TX and RX state machines are released from reset, the McASP triggers EDMA events for transmit and recieve operations. The first audio sample is received in RX buffer-0 via main paRAM set 0. Since it is linked to paRAM set 40, after receiving the first sample, EDMA resumes receiving data in RX buffer-0 via paRAM set 40. Similarly, the main paRAM set-1 enables transmssion from the loop buffer. When the main paRAM set expires, paRAM set 42 continuously transmits data from the loop buffer.
Once the EDMA reception is complete in RX Buffer-0, the application copies the RX Buffer-0 to TX Buffer-0 and updates the link paRAM set 42 to send data from TX Buffer-0. The paRAM set 42 is also linked to paRAM set 43. While the TX buffer-0 is being transmitted, the EDMA receives data in RX buffer-1 via paRAM set 41. Hence the paRAM set 42 is updated to receive data in RX buffer-2.
After the RX Buffer-1 is filled, it copies to TX Buffer-1 and the paRAM set 43 is updated to send from TX Buffer-1. After the EDMA transmission from TX Buffer-0 completes, the EDMA immediately starts transmitting from TX Buffer-1 since the paRAM set 42 is linked to paRAM set 43. During this time, the EDMA receives data in RX Buffer-2.
After the RX Buffer-2 is filled, it is copied to TX Buffer-2 and the paRAM set 42 is updated to send from TX Buffer-2. After the EDMA transmission from TX Buffer-1 completes, the EDMA immediately starts transmitting from TX Buffer-2 since the paRAM set 43 is linked to paRAM set 42. During this time, the EDMA receives data in RX Buffer-0.
After the RX Buffer-0 is filled, it is copied to TX Buffer-0 and the paRAM set 43 is updated to send from TX Buffer-0. After the EDMA transmission from TX Buffer-2 completes, the EDMA immediately starts transmitting from TX Buffer-0 since the paRAM set 42 is linked to paRAM set 43. During this time, the EDMA receives data in RX Buffer-1.
The EDMA data transfer resumes in the same sequence as explained in the above steps since the paRAM sets are programmed appropriately.