Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 C6000 Integration Workshop

Similar presentations


Presentation on theme: "Chapter 4 C6000 Integration Workshop"— Presentation transcript:

1 Chapter 4 C6000 Integration Workshop
Using the EDMA Chapter 4 C6000 Integration Workshop Technical Training Organization T TO Copyright © 2005 Texas Instruments. All rights reserved.

2 Goals for Chapter 4… CPU EDMA Channel We will learn how to: buf0 buf1
Use the EDMA to transfer data from one location to another Technical Training Organization T TO

3 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

4 Chip Support Library CSL Module Description Cache Cache & internal memory CHIP Specifies device type CSL CSL initialization function DAT Simple block data move DMA DMA (for ‘0x devices) EDMA Enhanced DMA (for ‘1x dev) EMIF External Memory I/F EMIFA EMIFB C64x EMIF’s GPIO General Purpose Bit I/O HPI Host Port Interface I2C I2C Bus Interface IRQ Hardware Interrupts McASP Audio Serial Port McBSP Buffered Serial Port PCI PCI Interface PLL Phase Lock Loop PWR Power Down Modes TCP Turbo Co-Processor TIMER On-chip Timers UTOPIA Utopia Port (ATM) VCP Viterbi Co-Processor XBUS eXpansion Bus C-callable library that supports programming of on-chip peripherals Supports peripherals in three ways: Resource Management (functions) Verify if periph is available “Check-out” a peripheral Simplifies Configuration Data structures Config functions Macros improve code readability You still have to know what you want the peripherals to do, CSL just simplifies the code and maintenance The best way to understand CSL is to look at an example...

5 General Procedure for using CSL
1. Include Header Files Library and individual module header files #include <csl.h> #include <csl_timer.h> Timer Example:

6 General Procedure for using CSL
1. Include Header Files Library and individual module header files 2. Declare Handle For periph’s with multiple resources #include <csl.h> #include <csl_timer.h> TIMER_Handle myHandle; Timer Example:

7 General Procedure for using CSL
1. Include Header Files Library and individual module header files 2. Declare Handle For periph’s with multiple resources 3. Define Configuration Create variable of configuration values #include <csl.h> #include <csl_timer.h> TIMER_Handle myHandle; TIMER_Config myConfig = {control, period, counter}; Timer Example:

8 General Procedure for using CSL
1. Include Header Files Library and individual module header files 2. Declare Handle For periph’s with multiple resources 3. Define Configuration Create variable of configuration values 4. Open peripheral Reserves resource; returns handle #include <csl.h> #include <csl_timer.h> TIMER_Handle myHandle; TIMER_Config myConfig = {control, period, counter}; myHandle = TIMER_open(TIMER_DEVANY, ...); Timer Example:

9 General Procedure for using CSL
1. Include Header Files Library and individual module header files 2. Declare Handle For periph’s with multiple resources 3. Define Configuration Create variable of configuration values 4. Open peripheral Reserves resource; returns handle 5. Configure peripheral Applies your configuration to peripheral #include <csl.h> #include <csl_timer.h> TIMER_Handle myHandle; TIMER_Config myConfig = {control, period, counter}; myHandle = TIMER_open(TIMER_DEVANY, ...); TIMER_config(myHandle, &myConfig); Timer Example: Technical Training Organization T TO

10 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
EDMA Overview EDMA Example Programming EDMA with CSL Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

11 How To Move Blocks of Memory?
A0 A1 A2 A3 A4 A5 C6000 CPU Load Store Takes DSP MIPs What would be better than using the CPU?

12 How To Move Blocks of Memory?
A0 A1 A2 A3 A4 A5 C6000 CPU Load Store Takes DSP MIPs Enhanced DMA (EDMA) Direct Memory Access Can directly access memory No CPU MIPs Technical Training Organization T TO To do its job, what info does the EDMA need?

13 EDMA Overview EDMA Channel Source Transfer Count Destination
Source Transfer Count Destination EDMA requires transfer parameters Most obvious: Src, Dest, Count

14 EDMA Overview EDMA Channel Options Index Link Addr Count Reload Source
Options Index Link Addr Count Reload Source Transfer Count Destination 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

15 EDMA Overview EDMA EDMA Channel Channel 63 (15) Channel 1 Channel 2
... Channel 0 EDMA C64x has 64 channels C67x has 16 channels EDMA Channel Options Index Link Addr Count Reload Source Transfer Count Destination 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 Technical Training Organization T TO How much does the EDMA move?

16 EDMA - How much to move Element The smallest piece of information
transferred by the EDMA is called ... ESIZE 00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd ESIZE Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count

17 EDMA - How much to move . . . . Block Frame Element Frame 1 Frame 2
Frame M Block . . 16 31 # Frames (M-1) Elem 1 Elem 2 Elem N Frame . . # Elements (N) 15 Element ESIZE 00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd ESIZE Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count

18 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
EDMA Overview EDMA Example Programming EDMA with CSL Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

19 EDMA Example (Src: loc_8) 8-bit Values Goal:
1 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 10 11 Goal: Transfer 4 elements from loc_8 to myDest myDest: 8 bits 8 9 10 11 8 9 10 11 8 9 10 11 ESIZE 00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd ESIZE 10 Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count # Elements 15 16 31 # Frames (less one)

20 EDMA Example (Src: loc_8) 8-bit Values Goal:
1 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 10 11 Goal: Transfer 4 elements from loc_8 to myDest myDest: 8 bits 8 9 10 11 8 9 10 11 8 9 10 11 ESIZE 00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd ESIZE 10 Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count # Elements 4 15 16 31 # Frames (less one) Do we need to increment Source and Dest?

21 Addr Update Mode (SUM/DUM)
EDMA Example (Src: loc_8) 8-bit Values 1 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 10 11 Goal: Transfer 4 elements from loc_8 to myDest myDest: 8 bits 8 9 10 11 8 9 10 11 8 9 10 11 00: fixed (no modification) 01: inc by element size 10: dec by element size 11: index Addr Update Mode (SUM/DUM) SUM DUM ESIZE 00: 32-bits 01: 16-bits 10: 8-bits 11: rsvd FS Frame Sync 0: Off 1: On ESIZE 10 SUM 01 DUM FS 1 Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count # Elements 4 15 16 31 # Frames (less one) How do we program the EDMA?

22 Programming the Traditional Way
EDMA Reg Values options 0x source &loc_8 count 0x dest &myDest index 0x rld:lnk 0x Traditional Way to Setup Peripherals Determine register field values Compute Hex value for register Write hex values to register with C Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count ESIZE 10 # Elements 4 15 16 31 # Frames (less one) FS 1 SUM 01 DUM Is there an easier way to program these registers?

23 CSL – An Easier Way to Program Peripherals
Chip Support Library (CSL) consists of: Data Types Define data structures used by CSL functions EDMA_Handle EDMA_Config Functions Used to configure and manage resources EDMA_config() EDMA_setChannel() Macros Improve code readability & decrease errors EDMA_OPT_RMK() EDMA_SRC_OF() EDMA_Config myConfig = { 0x , // options &loc_8, // source 0x , // count &myDest, // destination 0x , // index 0x // reload:link }; Options Source Destination Index Link Addr Cnt Reload 31 0 Transfer Count Channel EDMA_config() Technical Training Organization T TO

24 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
EDMA Overview EDMA Example Using CSL Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

25 EDMA Programming in 5 Easy Steps
1 Include the necessary header files #include <csl.h> #include <csl_edma.h> 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 = { }; Let’s learn more about the config structure…

26 3. EDMA Config Structure EDMA Parameter Values
options 0x source &loc_8 count 0x dest &myDest index 0x rldcnt:lnk 0x 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(0x ), EDMA_DST_OF(myDest), EDMA_IDX_OF(0), EDMA_RLD_OF(0) }; _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)

27 EDMA Programming in 5 Easy Steps
1 Include the necessary header files #include <csl.h> #include <csl_edma.h> 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(), … }; 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); Technical Training Organization T TO

28 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
EDMA Overview EDMA Example Using CSL Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

29 EDMA Events 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 run Set an event by writing to the EDMA’s Event Register (ER) Conveniently, a CSL function can set the ER bit for us: EDMA Event Input 1 ER EDMA Channels 1 EDMA_setChannel(hMyChan) 2 Technical Training Organization T TO

30 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
EDMA Overview EDMA Example Using CSL Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

31 Exercise 1 (Takes 20 Minutes)
Instructors, give students 20 Minutes to do exercise; Spend 10 mins reviewing These answers will be used during upcoming lab BUFFSIZE = 32 x 16 gBuf0 EDMA gBuf1 Using the space provided in Student Notes, write the code to initialize the EDMA. Here’s a few Hints: Follow the 5 steps we just discussed for writing CSL code Here are the config values for options not yet discussed: Low priority (PRI) Single dimensional source & dest (2DS, 2DD) Set TCC to 0 TCINT to off LINK to no Set reload and index values to 0 Technical Training Organization T TO

32 Exercise 1, Steps 1-2 Specify the appropriate include file(s):
Declare an EDMA handle named hEdma. Fill out the values for gEdmaConfig so that it moves the contents of gBuf0 to gBuf1. #include <csl.h> #include <csl_edma.h> #include “sine.h” EDMA_Handle hEdma; see next slide ... Technical Training Organization T TO

33 Exercise 1, Step 3: EDMA_Config
EDMA_Config gEdmaConfig = { EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, // Priority? EDMA_OPT_ESIZE_16BIT, // Element size? EDMA_OPT_2DS_NO, // Is it a 2 dimensional src? EDMA_OPT_SUM_INC, // Src update mode? EDMA_OPT_2DD_NO, // Is it a 2 dimensional dst? EDMA_OPT_DUM_INC, // Dest update mode? EDMA_OPT_TCINT_NO, // Cause EDMA interrupt? EDMA_OPT_TCC_OF( 0 ), // Transfer complete code? EDMA_OPT_LINK_NO, // Enable linking (autoinit)? EDMA_OPT_FS_YES // Use frame sync? ), EDMA_SRC_OF( gBuf0 ), // src address? EDMA_CNT_OF( BUFFSIZE ), // Count = buffer size EDMA_DST_OF( gBuf1 ), // dest address? EDMA_IDX_OF( ), // frame/element index value? EDMA_RLD_OF( ) // reload };

34 Exercise 1, Steps 4-6 Request any available EDMA channel from CSL to perform the transfer: Configure the EDMA channel you opened: How would you trigger this channel to run? hEdma = EDMA_open(EDMA_CHA_ANY, EDMA_OPEN_RESET); EDMA_config(hEdma, &gEdmaConfig); EDMA_setChannel(hEdma); Technical Training Organization T TO

35 Outline Chip Support Library (CSL) Direct Memory Access (EDMA)
Events – Triggering the EDMA Exercise Lab 4 Technical Training Organization T TO

36 Lab 4 – Programming the EDMA
CPU EDMA gBuf0 gBuf1 EDMA Goals: CPU generates 32 sine values into gBuf0 EDMA transfers 32 elements from gBuf0 to gBuf1 Technical Training Organization T TO

37 Hardware Interrupts (HWI)
Click Here for Chapter 5 Hardware Interrupts (HWI) Chapter 4: Optional Topics DMA vs. EDMA (e.g. C6701 uses DMA) EDMA Channel Ctrl vs. EDMA Transfer Controller QDMA (vs. EDMA) DAT EDMA “Alternate” Options (C64x only) Additional HWI topics NMIE ICR, ISR ISTP Interrupt Selector Saving Context (3 methods) HWI Dispatcher Using the interrupt keyword HWI_enter/_exit macros in Assembly Chaining EDMA channels Interrupts and the DMA (vs. EDMA) Secondary Control Register DMA pins Technical Training Organization T TO

38 Hardware Interrupts (HWI)
Click Here for Chapter 5 Hardware Interrupts (HWI) Chapter 4: Optional Topics DMA vs. EDMA (e.g. C6701 uses DMA) EDMA Channel Ctrl vs. EDMA Transfer Controller QDMA (vs. EDMA) DAT EDMA “Alternate” Options (C64x only) Additional HWI topics NMIE ICR, ISR ISTP Interrupt Selector Saving Context (3 methods) HWI Dispatcher Using the interrupt keyword HWI_enter/_exit macros in Assembly Chaining EDMA channels Interrupts and the DMA (vs. EDMA) Secondary Control Register DMA pins Technical Training Organization T TO

39 Hardware Interrupts (HWI)
Click Here for Chapter 5 Hardware Interrupts (HWI) Chapter 4: Optional Topics DMA vs. EDMA (e.g. C6701 uses DMA) EDMA Channel Ctrl vs. EDMA Transfer Controller QDMA (vs. EDMA) DAT EDMA “Alternate” Options (C64x only) Additional HWI topics NMIE ICR, ISR ISTP Interrupt Selector Saving Context (3 methods) HWI Dispatcher Using the interrupt keyword HWI_enter/_exit macros in Assembly Chaining EDMA channels Interrupts and the DMA (vs. EDMA) Secondary Control Register DMA pins Technical Training Organization T TO

40 DAT Block copy module DAT Functions DAT is device independent
Simply moves (or fills) a block of data No sync or ints are provided DAT Functions DAT_busy DAT_close DAT_copy DAT_fill DAT_open DAT_setPriority DAT_wait DAT_copy2d DAT is device independent Implemented for all C5000/C6000 devices It uses whatever DMA capability is available Uses QDMA, when available Technical Training Organization T TO

41 DAT Init Functions Run Functions Feedback Functions
success/fail = DAT_open (DAT_CHAANY, priority, flag); DAT_setPriority (DAT_PRI_LOW); Run Functions transfer ID = DAT_fill (*dest, 16-bit count, 32-bit value); transfer ID = DAT_copy (*source, *dest, 16-bit count); transfer ID = DAT_copy2d (…); Feedback Functions 0 if done = DAT_busy (transfer ID); DAT_wait (id); // where id = transfer ID, or // DAT_XFRID_WAITALL, // DAT_XFRID_WAITNONE Free Function DAT_close ( ); Technical Training Organization T TO

42 CSL: DAT Example void myDat(void) { #define BUFFSZ 4096
static Uint8 BuffA[BUFFSZ]; Uint8 BuffB[BUFFSZ]; Uint32 FillValue,XfrId; DAT_open(DAT_CHAANY, DAT_PRI_HIGH); FillValue = 0x00C0FFEE; /* Set the fill value */ XfrId = DAT_fill(BuffA, BUFFSZ, &FillValue); /* Perform the fill operation */ DAT_wait(XfrId); /* Wait for completion */ XfrId = DAT_copy(BuffA, BuffB, BUFFSZ); /* copy A -> B */ if (DAT_busy(XfrId) == 0) then /* Check if copy completed, yet */ printf("Not done yet"); DAT_close(); } Technical Training Organization T TO

43 Hardware Interrupts (HWI)
Click Here for Chapter 5 Hardware Interrupts (HWI) Chapter 4: Optional Topics DMA vs. EDMA (e.g. C6701 uses DMA) EDMA Channel Ctrl vs. EDMA Transfer Controller QDMA (vs. EDMA) DAT EDMA “Alternate” Options (C64x only) Additional HWI topics NMIE ICR, ISR ISTP Interrupt Selector Saving Context (3 methods) HWI Dispatcher Using the interrupt keyword HWI_enter/_exit macros in Assembly Chaining EDMA channels Interrupts and the DMA (vs. EDMA) Secondary Control Register DMA pins Technical Training Organization T TO

44 Technical Training Organization TTO ti


Download ppt "Chapter 4 C6000 Integration Workshop"

Similar presentations


Ads by Google