Upload
dinozoor
View
222
Download
0
Embed Size (px)
Citation preview
8/2/2019 Using the EDMA
1/9
Using the EDMA
IntroductionIn this chapter, you will learn how to program the EDMA to perform a transfer of data from onebuffer to another.
Learning Objectives
EDMA
Goals for Chapter 4
CPUbuf0
Channel
buf1
We will learn how to:Use the EDMA to transfer data from one location to another
TechnicalTr ainingOrganization
T TO
C6000 Integration Workshop - Using the EDMA 4 - 1
8/2/2019 Using the EDMA
2/9
Chip Support Library (CSL)
Chapter Topics
Using the EDMA........................................................................................................................................ 4-1Chip Support Library (CSL) ................................................................................................................... 4-3
Enhanced Direct Memory Access (EDMA)............................................................................................. 4-4Introduction ........................................................................................................................................ 4-4Overview ............................................................................................................................................ 4-5Definitions .......................................................................................................................................... 4-5Example.............................................................................................................................................. 4-6Programming 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-14DMA (vs. EDMA).............................................................................................................................4-20EDMA: Channel Controller vs. Transfer Controller ........... .......... ........... ........... .......... ............ .......4-22QDMA...............................................................................................................................................4-23DAT (CSL module) ...........................................................................................................................4-24EDMA: Alternate Option Fields.......................................................................................................4-26
4 - 2 C6000 Integration Workshop - Using the EDMA
8/2/2019 Using the EDMA
3/9
Chip Support Library (CSL)
Chip Support Library (CSL)
Chip Support LibraryC-callable library that supportsprogramming of on-chip peripherals
Supports peripherals in three ways:
1. Resource Management (functions)Verify if periph is availableCheck-out a peripheral
2. Simplifies ConfigurationData structuresConfig functions
3. Macros improve code readability
You still have to know what you wantthe peripherals to do, CSL justsimplifies the code and maintenance
Viterbi Co-Processor VCPeXpansion BusXBUS
Utopia Port (ATM)UTOPIAOn-chip TimersTIMERTurbo Co-Processor TCPPower Down ModesPWRPhase Lock LoopPLLPCI InterfacePCIBuffered Serial PortMcBSP Audio Serial PortMcASP
Hardware InterruptsIRQI2C Bus InterfaceI2CHost Port InterfaceHPIGeneral Purpose Bit I/OGPIO
C64x EMIFsEMIFAEMIFB
External Memory I/FEMIFEnhanced DMA (for 1x dev)EDMADMA (for 0x devices)DMASimple block data moveDATCSL initialization functionCSLSpecifies device typeCHIPCache & internal memoryCache DescriptionCSL Module
The best way to understand CSLis to look at an example...
1. Include Header FilesLibrary and individual module header files
2. Declare HandleFor periphs with multiple resources
3. Define ConfigurationCreate variable of configuration values
4. Open peripheralReserves resource; returns handle
5. Configure peripheralApplies your configuration to peripheral
1. Include Header FilesLibrary and individual module header files
2. Declare HandleFor periphs with multiple resources
3. Define ConfigurationCreate variable of configuration values
4. Open peripheralReserves resource; returns handle
5. Configure peripheralApplies your configuration to peripheral
General Procedure
for using CSL
1. #include < csl.h >#include < csl_timer.h >
2. TIMER_Handle myHandle ;3. TIMER_Config myConfig
myConfig );
= {control, period, counter };
4. myHandle = TIMER_open ( TIMER_DEVANY, ... );5. TIMER_config ( myHandle , &
TimerExample:
Technical TrainingOrganization
T TO
C6000 Integration Workshop - Using the EDMA 4 - 3
8/2/2019 Using the EDMA
4/9
Enhanced Direct Memory Access (EDMA)
Enhanced Direct Memory Access (EDMA)
IntroductionThe EDMA is a peripheral that can be set up to copy data from one place to another without theCPUs intervention. The EDMA can be setup to copy data or program from a source(external/internal memory, or a serial port) to a destination (e.g. internal memory). After thistransfer completes, the EDMA can autoinitialize itself and perform the same transfer again, orit can be reprogrammed.
How To Move Blocks of Memory?mem2mem1 A0
A1A2A3A4A5
C6000
CPULoadStore
Takes DSP MIPs
Enhanced DMA (EDMA)Direct Memory AccessCan directly access memory
No CPU MIPs
To do its job, what info does the EDMA need?TechnicalTraining
Organization
T TO
4 - 4 C6000 Integration Workshop - Using the EDMA
8/2/2019 Using the EDMA
5/9
Enhanced Direct Memory Access (EDMA)
Overview
EDMA Overview
Source
DestinationTransfer Count
Options
IndexLink AddrCount Reload
31 16 15 0
EDMA requires transfer parametersMost obvious: Src, Dest, Count
Each channel has also has options for:Data sizeChannel PriorityAutoinit (linking)Inc/dec src & dest addresses
Channel 63 (15)
Channel 1
Channel 2
...
Channel 0
EDMA
C64x has 64 channels
C67x has 16 channels
EDMA Channel
How much does the EDMA move?Technical TrainingOrganization
T TO
Definitions
EDMA - How much to move
Element
ESIZE
00: 32-bits01: 16-bits10: 8-bits11: rsvd
ESIZE
Elem 1Elem 2
Elem N
Frame
..
# Elements (N)015
Frame 1Frame 2
Frame M
Block
..
1631
# Frames (M-1)
OptionsSource
DestinationIndex
Link Addr Cnt Reload31 0
Transfer Count
C6000 Integration Workshop - Using the EDMA 4 - 5
8/2/2019 Using the EDMA
6/9
Enhanced Direct Memory Access (EDMA)
ExampleHow do we setup the six EDMA parameters registers to transfer 4 byte-wide elements from loc_8to myDest ?
EDMA Example
myDest:
8 bits
89
1011
(Src: loc_8)
8-bit Values1 2 3 4 5 6
7 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
8 9 1 0 118 9 1 0 1189
1011
ESIZE
00: 32-bits01: 16-bits10: 8-bits11: rsvd
OptionsSource
DestinationIndex
Link Addr Cnt Reload31 0
Transfer Count
ESIZE10
Goal:
Transfer 4 elementsfrom loc_8 to myDest
# Elements4
0151631
# Frames (less one)0
FS
FS
Frame Sync0: Off1: On
00: fixed (no modification)01: inc by element size10: dec by element size11: index
Addr Update Mode (SUM/DUM)
SUM DUM
How do we program the EDMA?
SUM01
DUM01
FS1
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 bemodified between element reads and writes. Since our example above moves 4consecutive byte elements and writes them to 4 consecutive locations, both SUM andDUM 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 istriggered 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 thenext chapter.
4 - 6 C6000 Integration Workshop - Using the EDMA
8/2/2019 Using the EDMA
7/9
Using CSL
Programming the EDMA (the traditional way)
Programming the Traditional WayEDMA Reg Values
options 0x51200001source &loc_8count 0x00000004dest &myDestindex 0x00000000rld:lnk 0x00000000
EDMA Reg Valuesoptions 0x51200001source &loc_8count 0x00000004dest &myDestindex 0x00000000rld:lnk 0x00000000
Traditional Way to Setup Peripherals
1. Determine register field values
2. Compute Hex value for register
3. Write hex values to register with C
Is there an easier way to program these registers?
OptionsSource
DestinationIndex
Link Addr Cnt Reload31 0
Transfer Count
ESIZE10
# Elements4
0151631
# Frames (less one)0
FS1
SUM01
DUM01
Using CSL
As shown below, we basically want to get the six 32-bit values we calculated for each registerinto the EDMA channel parameter location.
CSL An Easier Way to Program PeripheralsChip Support Library (CSL) consists of:
Data Types Define data structures used by CSL functionsEDMA_HandleEDMA_Config
Functions Used to configure and manage resourcesEDMA_config()EDMA_setChannel()
Macros Improve code readability & decrease errorsEDMA_OPT_RMK()EDMA_SRC_OF()
OptionsSource
DestinationIndex
Link Addr Cnt Reload31 0
Transfer Count
ChannelEDMA_Config myConfig = {0x51200001, // options&loc_8, // source0x00000004, // count&myDest, // destination0x00000000, // index0x00000000 // reload:link
};
EDMA_Config myConfig = {0x51200001, // options&loc_8, // source0x00000004, // count&myDest, // destination0x00000000, // index0x00000000 // reload:link
};
EDMA_config()
TechnicalTr ainingOrganization
T TO
C6000 Integration Workshop - Using the EDMA 4 - 7
8/2/2019 Using the EDMA
8/9
Using CSL
Here are the 5 basic steps to accomplishing this using CSL:
EDMA Programming in 5 Easy Steps
2 Declare a handle (will point to an EDMA channel)EDMA_Handle hMyChan;
3 Fill in the config structure (values to program into EDMA)EDMA_Config myConfig = {
EDMA_OPT_RMK(), };
1 Include the necessary header files#include #include
4 Open a channel (requests any avail channel; and reserves it)hMyChan = EDMA_open( EDMA_CHA_ANY, EDMA_OPEN_RESET) ;
5 Configure channel (writes config structure to assigned channel)EDMA_config(hMyChan, &myConfig);
TechnicalTr ainingOrganization
T TO
Looking more closely at the Config structure?
You can see we used CSL macros (_RMK and _OF macros) to create the six 32-bit hex values.The beauty of these macros is how easy they are to read and write. This will come in handy whenwe need to debug our code, or later on when we need to maintain the code.
EDMA Parameter Valuesoptions 0x51200001source &loc_8count 0x00000004dest &myDestindex 0x00000000rldcnt:lnk 0x00000000
EDMA Parameter Valuesoptions 0x51200001source &loc_8count 0x00000004dest &myDestindex 0x00000000rldcnt:lnk 0x00000000
EDMA_Config myConfig = {EDMA_OPT_RMK(
EDMA_OPT_PRI_LOW,EDMA_OPT_ESIZE_8BIT,EDMA_OPT_2DS_NO,EDMA_OPT_SUM_INC,EDMA_OPT_2DD_NO,EDMA_OPT_DUM_INC,
EDMA_OPT_TCINT_YES,EDMA_OPT_TCC_OF(5),EDMA_OPT_LINK_NO,EDMA_OPT_FS_YES),
EDMA_SRC_OF(loc_8),EDMA_CNT_OF(0x00000004),EDMA_DST_OF(myDest),EDMA_IDX_OF(0),EDMA_RLD_OF(0)
};
EDMA_Config myConfig = {EDMA_OPT _RMK(
EDMA_OPT_PRI_LOW,EDMA_OPT_ ESIZE _8BIT,EDMA_OPT_2DS_NO,EDMA_OPT_ SUM _INC,EDMA_OPT_2DD_NO,EDMA_OPT_ DUM _INC,
EDMA_OPT_TCINT_YES,EDMA_OPT_TCC_OF(5),EDMA_OPT_LINK_NO,EDMA_OPT_ FS _YES),
EDMA_SRC _OF ( loc_8 ),EDMA_CNT _OF ( 0x00000004 ),EDMA_DST _OF ( myDest ),EDMA_IDX _OF (0),EDMA_RLD _OF (0)
};
_RMK (register make) createsa single hex value from optionsymbols you select
_OF macro performs anyneeded casting (and providesvisual consistency)
Highlighted in BLUE are theoptions discussed thus far(esize, sum, dum, fs, src, cnt, dst)
4 - 8 C6000 Integration Workshop - Using the EDMA
8/2/2019 Using the EDMA
9/9
EDMA Events Triggering the EDMA
EDMA Events Triggering the EDMA
EDMA Events
EDMAChannels
2
1
0
EDMA_setChannel( hMyChan )
EDMA Event Input
0
1
0
0
ER
How do you trigger an EDMA channel to run,that is, start copying a block of memory?
Channels must receive a start event in order to runSet an event by writing to the EDMAs Event Register (ER)
Conveniently, a CSL function can set the ER bit for us:
Technical TrainingOrganization
T TO
In Chapter 6 we will show how to use interrupt events to trigger the EDMA. This will come inhandy 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.
C6000 Integration Workshop - Using the EDMA 4 - 9