Functional Description
11.3.19.4.4 Ping-Pong Buffering
Although the previous configuration allows the EDMA3 to service a peripheral continuously, it presents a
number of restrictions to the CPU. Because the input and output buffers are continuously being
filled/emptied, the CPU must match the pace of the EDMA3 very closely to process the data. The EDMA3
receive data must always be placed in memory before the CPU accesses it, and the CPU must provide
the output data before the EDMA3 transfers it. Though not impossible, this is an unnecessary challenge. It
is particularly difficult in a 2-level cache scheme.
Ping-pong buffering is a simple technique that allows the CPU activity to be distanced from the EDMA3
activity. This means that there are multiple (usually two) sets of data buffers for all incoming and outgoing
data streams. While the EDMA3 transfers the data into and out of the ping buffers, the CPU manipulates
the data in the pong buffers. When both CPU and EDMA3 activity completes, they switch. The EDMA3
then writes over the old input data and transfers the new output data.
shows the ping-pong
scheme for this example.
To change the continuous operation example, such that a ping-pong buffering scheme is used, the
EDMA3 channels need only a moderate change. Instead of one parameter set, there are two; one for
transferring data to/from the ping buffers and one for transferring data to/from the pong buffers. As soon
as one transfer completes, the channel loads the PaRAM set for the other and the data transfers continue.
shows the EDMA3 channel configuration required.
Each channel has two parameter sets, ping and pong. The EDMA3 channel is initially loaded with the ping
parameters (
). The link address for the ping set is set to the PaRAM offset of the pong
parameter set (
). The link address for the pong set is set to the PaRAM offset of the ping
parameter set (
). The channel options, count values, and index values are all identical
between the ping and pong parameters for each channel. The only differences are the link address
provided and the address of the data buffer.
11.3.19.4.4.1 Synchronization with the CPU
To utilize the ping-pong buffering technique, the system must signal the CPU when to begin to access the
new data set. After the CPU finishes processing an input buffer (ping), it waits for the EDMA3 to complete
before switching to the alternate (pong) buffer. In this example, both channels provide their channel
numbers as their report word and set the TCINTEN bit to generate an interrupt after completion. When
channel 15 fills an input buffer, the E15 bit in the interrupt pending register (IPR) is set; when channel 12
empties an output buffer, the E12 bit in IPR is set. The CPU must manually clear these bits. With the
channel parameters set, the CPU polls IPR to determine when to switch. The EDMA3 and CPU could
alternatively be configured such that the channel completion interrupts the CPU. By doing this, the CPU
could service a background task while waiting for the EDMA3 to complete.
930
Enhanced Direct Memory Access (EDMA)
SPRUH73H – October 2011 – Revised April 2013
Copyright © 2011–2013, Texas Instruments Incorporated