7.4.7 Ping-Pong
Communication peripherals often use ping-pong buffers. Ping-pong buffers allow the CPU to process data in one buffer while a periph-
eral transmits or receives data in the other buffer.
Both transmit and receive ping-pong buffers are easily implemented using the LDMA. In either case, this requires two descriptors as
shown in
Figure 7.10 Infinite Ping-Pong Example on page 118
. The LINKADDR field of the LINK member should point to the other
descriptor. Using two adjacent descriptors and relative link addressing ensures the descriptors are easily reloadable.
CTRL
SRC
DST
LINK
A
Memory
LINKADDR = 0x00000010
LINKMD = 1
A
B
CTRL
SRC
DST
LINK
B
LINKADDR = 0xFFFFFFF0
LINKMD = 1
Figure 7.10. Infinite Ping-Pong Example
A
receiver
ping-pong buffer controller consists of two buffers and two descriptors stored in memory that point to the two buffers. Once
initialized, as the peripheral receives data, it will fill the first buffer. Once the first buffer is full, it will link automatically to the second
buffer and generate an interrupt. Software will then process the data in the first buffer while the LDMA is transferring data to the second
buffer. For a receiver ping-pong buffer each descriptor should link to the other descriptor. The link bit should be set to provide infinite
ping pong between the two buffers. The DONIFS bit in each descriptor should be set to generate an interrupt on the completion of each
descriptor.
• Descriptor A
• CTRL
• DONEIFS = 1
• other settings as desired
• SRCADDR = peripheral source address
• DSTADDR = memory destination address
• LINK = 0x00000013
• LINKADDR = 0x00000010 (next descriptor)
• LINK = 1 (link to next descriptor)
• LINKMD = 1 (relative addressing)
• Descriptor B
• CTRL
• DONEIFS = 1
• other settings as desired
• SRCADDR = peripheral source address
• DSTADDR = memory destination address
• LINK = 0xFFFFFFF3
• LINKADDR = 0xFFFFFFF0 (previous descriptor)
• LINK = 1 (link to previous descriptor)
• LINKMD = 1 (relative addressing)
For
transmitter
ping-pong buffer, software will fill the first buffer and then initiate the DMA transfer. The LDMA will transmit the first
buffer data while software is filling the second buffer. In this case, the two descriptors should point to each other, but not automatically
continue to the second buffer. The LINK bit should be cleared to zero. Once software has loaded the first buffer, it will use the
EFM32JG1 Reference Manual
LDMA - Linked DMA Controller
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 118