Professional Documents
Culture Documents
Using The EDMA
Using The EDMA
Using The EDMA
Introduction
In this chapter, you will learn how to program the EDMA to perform a transfer of data from one buffer to another.
EDMA
buf1
Channel
T TO
Technical Training Organization
4-1
Chapter Topics
Using the EDMA........................................................................................................................................ 4-1 Chip Support Library (CSL) ................................................................................................................... 4-3 Enhanced Direct Memory Access (EDMA)............................................................................................. 4-4 Introduction ........................................................................................................................................ 4-4 Overview ............................................................................................................................................ 4-5 Definitions .......................................................................................................................................... 4-5 Example.............................................................................................................................................. 4-6 Programming the EDMA (the traditional way) .................................................................................. 4-7 Using CSL ............................................................................................................................................... 4-7 Looking more closely at the Config structure?................................................................................... 4-8 EDMA Events Triggering the EDMA................................................................................................... 4-9 Exercise..................................................................................................................................................4-10 Lab 4 Overview ...................................................................................................................................4-13 Lab 4 ......................................................................................................................................................4-14 DMA (vs. EDMA).............................................................................................................................4-20 EDMA: Channel Controller vs. Transfer Controller ........................................................................4-22 QDMA...............................................................................................................................................4-23 DAT (CSL module) ...........................................................................................................................4-24 EDMA: Alternate Option Fields.......................................................................................................4-26
4-2
Resource Management (functions) Verify if periph is available Check-out a peripheral Simplifies Configuration Data structures Config functions Macros improve code readability
2.
3.
You still have to know what you want the peripherals to do, CSL just simplifies the code and maintenance
CSL Module Cache CHIP CSL DAT DMA EDMA EMIF EMIFA EMIFB GPIO HPI I2C IRQ McASP McBSP PCI PLL PWR TCP TIMER UTOPIA VCP XBUS
Description Cache & internal memory Specifies device type CSL initialization function Simple block data move DMA (for 0x devices) Enhanced DMA (for 1x dev) External Memory I/F C64x EMIFs General Purpose Bit I/O Host Port Interface I2C Bus Interface Hardware Interrupts Audio Serial Port Buffered Serial Port PCI Interface Phase Lock Loop Power Down Modes Turbo Co-Processor On-chip Timers Utopia Port (ATM) Viterbi Co-Processor eXpansion Bus
1. Include Header Files 1. Include Header Files Library and individual module header files Library and individual module header files 2. Declare Handle 2. Declare Handle For periphs with multiple resources For periphs with multiple resources 3. Define Configuration 3. Define Configuration Create variable of configuration values Create variable of configuration values 4. Open peripheral 4. Open peripheral Reserves resource; returns handle Reserves resource; returns handle 5. Configure peripheral 5. Configure peripheral Applies your configuration to peripheral Applies your configuration to peripheral
Timer Example:
T TO
Technical Training Organization
2. TIMER_Handle myHandle; 3. TIMER_Config myConfig = {control, period, counter}; 4. myHandle = TIMER_open(TIMER_DEVANY, ...); 5. TIMER_config(myHandle, &myConfig);
4-3
C6000
CPU Load Store Takes DSP MIPs Enhanced DMA (EDMA) Direct Memory Access Can directly access memory No CPU MIPs
T TO
Technical Training Organization
4-4
Overview
EDMA Overview
EDMA
Channel 0 Channel 1 Channel 2 ... Channel 63 (15) C64x has 64 channels C67x has 16 channels
EDMA Channel
Options Source Transfer Count Destination Index Count Reload
31 16 15
Link Addr
0
EDMA requires transfer parameters Most obvious: Src, Dest, Count Each channel has also has options for: Data size Channel Priority Autoinit (linking) Inc/dec src & dest addresses
T TO
Technical Training Organization
Definitions
Frame
Elem 1 Elem 2
Element
ESIZE
00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd
. .
Frame M
. .
Elem N
Options Source Transfer Count Destination Index Cnt Reload Link Addr 31 0
ESIZE
# Frames (M-1)
31 16 15
# Elements (N)
0
4-5
Example
How do we setup the six EDMA parameters registers to transfer 4 byte-wide elements from loc_8 to myDest?
EDMA Example
8-bit Values Goal: Transfer 4 elements from loc_8 to myDest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
myDest:
8 9 10 11
8 bits
FS
Frame Sync 0: Off 1: On
Options Source Transfer Count Destination Index Cnt Reload Link Addr 31 0
ESIZE 10
SUM 01
DUM 01 # Elements 4
FS 1
Looking at the EDMA parameters one register at a time: 1. Options: ESIZE should be self-explanatory based on our previous definitions. SUM and DUM fields indicate how the source and destination addresses are to be modified between element reads and writes. Since our example above moves 4 consecutive byte elements and writes them to 4 consecutive locations, both SUM and DUM are set to inc by element size. In future chapters, well use other values for them. Frame Sync (FS) indicates how much data should be moved whenever the EDMA is triggered to run. In our case, since we want to move the whole frame of data when the CPU starts the EDMA channel, we should set FS = 1. Later, when we use the McBSP, well want to change this value so the EDMA only moves one element per trigger event. 2. Source: Should have the source address of loc_8. 3. Transfer Counter: Will have the value 4. Actually, it is 0x 0000 0004. 4. Destination: gets the value of myDest. 5. Index: Were not using the index capability in this chapter. We will discuss this in chapter 7. 6. Reload/Linking: Again, this capability is not used in this chapter. Rather we cover it in the next chapter.
4-6
Using CSL
Options Source Transfer Count Destination Index Cnt Reload Link Addr 31 0
ESIZE 10
SUM 01
DUM 01 # Elements 4
FS 1
Using CSL
As shown below, we basically want to get the six 32-bit values we calculated for each register into the EDMA channel parameter location.
Channel EDMA_config()
Options Source Transfer Count Destination Index Cnt Reload Link Addr 31 0
4-7
Using CSL
EDMA_Handle hMyChan;
3 Fill in the config structure (values to program into EDMA)
EDMA_config(hMyChan, &myConfig);
_RMK (register make) creates a single hex value from option symbols you select _OF macro performs any needed casting (and provides visual consistency) Highlighted in BLUE are the options discussed thus far (esize, sum, dum, fs, src, cnt, dst)
EDMA_Config myConfig = { EDMA_Config myConfig = { EDMA_OPT_RMK( EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, EDMA_OPT_PRI_LOW, EDMA_OPT_ESIZE_8BIT, EDMA_OPT_ESIZE_8BIT, EDMA_OPT_2DS_NO, EDMA_OPT_2DS_NO, EDMA_OPT_SUM_INC, EDMA_OPT_SUM_INC, EDMA_OPT_2DD_NO, EDMA_OPT_2DD_NO, EDMA_OPT_DUM_INC, EDMA_OPT_DUM_INC, EDMA_OPT_TCINT_YES, EDMA_OPT_TCINT_YES, EDMA_OPT_TCC_OF(5), EDMA_OPT_TCC_OF(5), EDMA_OPT_LINK_NO, EDMA_OPT_LINK_NO, EDMA_OPT_FS_YES EDMA_OPT_FS_YES ), ), EDMA_SRC_OF(loc_8), EDMA_SRC_OF(loc_8), EDMA_CNT_OF(0x00000004), EDMA_CNT_OF(0x00000004), EDMA_DST_OF(myDest), EDMA_DST_OF(myDest), EDMA_IDX_OF(0), EDMA_IDX_OF(0), EDMA_RLD_OF(0) EDMA_RLD_OF(0) }; };
4-8
EDMA Channels 0 1 2
0 EDMA_setChannel(hMyChan) 1 0 0
T TO
Technical Training Organization
In Chapter 6 we will show how to use interrupt events to trigger the EDMA. This will come in handy when we use the McBSP to tell the EDMA when to transfer a value to it, or when to pick up a value from its receive register.
4-9