AN2108 Freescale Semiconductor / Motorola, AN2108 Datasheet

no-image

AN2108

Manufacturer Part Number
AN2108
Description
AN2108 Programming the DSP56307/DSP56311 EFCOP in C Using Taskings Tool Suite
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
MOTOROLA
Semiconductor Products Sector Application Note
Programming the
DSP56307/DSP56311 EFCOP in C
Using TASKING’s Tool Suite
Emmanuel Roy, David Crawford, Iain Stirling
© Motorola, Inc. 2001
In the rapidly evolving arena of telecommunications, the need for
digital signal processors (DSPs) with ever greater performance
continually leads to new high technology, low-cost devices with
low power consumption and dissipation. The
DSP56307/DSP56311 processors are recent powerful additions to
Motorola’s high performance DSP56300 family of
DSPs [1],[2],[4]. Although the DSP56307/DSP56311 specifically
target the telecommunications marketplace, they are also ideally
suited as general-purpose devices.
Among the innovative features of the DSP56307/DSP56311
processors is a dedicated filtering hardware unit, the Enhanced
Filtering Coprocessor (EFCOP), that can potentially double the
overall speed performance. High-level programming languages
such as C and C++ greatly simplify the processors’ programing
tasks (including the EFCOP), making the DSP56307/DSP56311
processors accessible to any engineer, from DSP novices to DSP
experts. The combination of high processing performance and the
ability to program in high-level languages eases
DSP56307/DSP56311 implementation, reduces application
development time, and improves code readability and
maintenance.
This application note examines the EFCOP modes of operation
and explains how to configure and activate these modes from C
using TASKING’s Tool Suite for the DSP56300 family [6]. The
code was developed and tested on a DSP56307 evaluation
module, but the development approach, the EFCOP concepts, and
the C code examples provided here apply equally to the
DSP56311. The minor differences between the DSP56311
EFCOP and the DSP56307 EFCOP are stated in Section 7.
Finally, we recommend that you read this application note in
conjunction with Chapter 10 of the DSP56307 User’s Manual,
“Enhanced Filter Coprocessor” [1].
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
1
2
2.1
2.2
3
3.1
3.2
3.3
4
4.1
4.2
4.3
5
6
6.1
6.2
6.3
6.4
7
8
Programming Examples ......... 2
EFCOP Overview .................... 2
EFCOP Modes ................................. 4
EFCOP Programming Model .......... 4
TASKING Tool Suite .............. 8
File Requirements for Programming
FDM and FCM Source Code
EFCOP Register Access in
Transferring Data to and
from the EFCOP.................... 11
Polling............................................ 12
Direct Memory Access (DMA) ..... 13
Interrupts........................................ 17
Application Examples ........... 20
Software Installation and Concepts21
FIR Filter ....................................... 21
Adaptive FIR filter......................... 24
Residu Function from the GSM
DSP56311 EFCOP and DSP56307
EFCOP Compared ................ 29
References .............................. 29
the EFCOP ...................................... 8
Declaration .................................... 10
TASKING C.................................. 10
EFR/AMR Vocoders27
EFCOP Initialization Mode. 19
Contents
Order Number: AN2108/D
Rev. 0, 5/2001

Related parts for AN2108

AN2108 Summary of contents

Page 1

... Go to: www.freescale.com Order Number: AN2108/D Rev. 0, 5/2001 Contents Programming Examples ......... 2 EFCOP Overview .................... 2 EFCOP Modes ................................. 4 EFCOP Programming Model .......... 4 TASKING Tool Suite .............. 8 File Requirements for Programming the EFCOP ...................................... 8 FDM and FCM Source Code Declaration .................................... 10 EFCOP Register Access in TASKING C.................................. 10 Transferring Data to and from the EFCOP ...

Page 2

Freescale Semiconductor, Inc. EFCOP Overview 1 Programming Examples Accompanying this application note are files containing examples of typical filtering configurations. Each example presents an overview of relevant theory, a description of implementation issues and techniques, and a C code example. ...

Page 3

Freescale Semiconductor, Inc. Alongside the dedicated FMAC unit, the DSP56307 EFCOP (see Figure 2) uses two memory data banks: • Filter Data Memory (FDM). Contains the filter input samples. This bank of memory is mapped to the bottom 4K words ...

Page 4

Freescale Semiconductor, Inc. EFCOP Overview 2.1 EFCOP Modes The EFCOP operates in several different modes, making it very flexible: • FIR filtering: — with real taps — with complex taps generating a complex output (that is, real and imaginary) for ...

Page 5

Freescale Semiconductor, Inc. Address Y:$FFFFB0 Y:$FFFFB1 Y:$FFFFB2 Y:$FFFFB3 Y:$FFFFB4 Y:$FFFFB5 Y:$FFFFB6 Y:$FFFFB7 Y:$FFFFB8 X:$0 .. X:$FFF Y:$0 .. Y:$FFF Table 2 lists the basic steps in programming the EFCOP, along with the register(s) involved in each step. Table 2. Overview ...

Page 6

Freescale Semiconductor, Inc. EFCOP Overview Table 2. Overview of Steps in Programming the EFCOP and Its Registers Step After the EFCOP has been triggered to begin filtering: Input data samples are fed into the EFCOP to trigger it into calculating ...

Page 7

Freescale Semiconductor, Inc. Address Generator FDM Memory X:$0 ... X:$FFF Automatic Transfer FMAC FDIR Input Samples Figure 3. EFCOP Modes of Operation FDM FDBA High x(k) + FCNT-1 Address x(k- Low Address FDBA+1 x(k-N+2) FDBA x(k-N+1) Figure ...

Page 8

... Target Hardware configuration: DSP56307, Unified Memory Map • Select Use Project specific locator control file 2. For details on TASKING, contact [6]. For details on the EDE tools suite, refer to [6],[7], and [8]. 3. For details on the description files, refer to [7]. Programming the DSP56307/DSP56311 EFCOP ...

Page 9

... Linker lk563 Object files .out Locator lc563 Absolute files .abs TASKING 37 Cross View Debugger RS232 Figure 5. Overview of TASKING Tools Suite Programming the DSP56307/DSP56311 EFCOP in C For More Information On This Product, Go to: www.freescale.com TASKING Tool Suite Command Convertor ONCE/JTAG DSP56307 EVM 9 ...

Page 10

Freescale Semiconductor, Inc. TASKING Tool Suite 3.2 FDM and FCM Source Code Declaration The FDM and FCM must be declared as arrays in the C source code with two specific names, FDM_buffer and FCM_buffer, respectively. These names coincide with the ...

Page 11

Freescale Semiconductor, Inc int I; }facr_type; This union is then defined as follows, which allows direct register access from the C code: #define FACR (*(facr_type _Y *)0xFFFFB5) Two different union accesses are possible: • Using the ‘I’ member ...

Page 12

Freescale Semiconductor, Inc. Transferring Data to and from the EFCOP These transfers are accomplished using either polling, DMA, or interrupts. All the different transfers rely on two status bits from the FCSR: • Filter Data Input Buffer Empty (FDIBE) bit ...

Page 13

Freescale Semiconductor, Inc. /**********************************************/ /*** EFCOP is now calculating output sample ***/ /**********************************************/ /*** Poll FDOBF until set ***/ while (FCSR.B.FDOBF == 0) {} output[n] = FDOR; /* Get output data sample from EFCOP */ } /* Repeat for next ...

Page 14

Freescale Semiconductor, Inc. Transferring Data to and from the EFCOP The appropriate DMA channel should be set to respond to requests from MDRQ11 or MDRQ12, as required. The EFCOP always DMA transfer occurs only if the appropriate DMA channel is ...

Page 15

Freescale Semiconductor, Inc. 4.2.2 EFCOP DMA Output Since the EFCOP output register, FDOR, is one word deep, a 1-D DMA transfer from the EFCOP is necessary. This type of transfer moves one word from the FDOR on each peripheral request. ...

Page 16

Freescale Semiconductor, Inc. Transferring Data to and from the EFCOP The configuration principles are as follows: • DMA Control Register (DCR): — DMA Transfer Mode (DTM) = word transfer triggered by request — DMA Request Source (DRS) = MDRQ12 (see ...

Page 17

Freescale Semiconductor, Inc. /* DDS = 00 /* DSS = 01 4.2.3 DMA and DSP56300 Core Interaction The DSP56300 core sets up the DMA channels. Then the EFCOP processes all of the data samples with no core intervention, freeing the ...

Page 18

Freescale Semiconductor, Inc. Transferring Data to and from the EFCOP Table 5 and Table 6 list the priorities corresponding to these settings. Table 5. Status Register Interrupt Masks I1 = SR[ Table 6. EFCOP Interrupt Priority ...

Page 19

Freescale Semiconductor, Inc. In TASKING C, a function is declared as an interrupt service routine using the special type qualifiers _long_interrupt and _fast_interrupt function declared as a fast interrupt cannot be implemented in two words or fewer, the ...

Page 20

Freescale Semiconductor, Inc. Application Examples Figure 8 shows the EFCOP data memory in initialized data mode. Although the FDM contains previous memory values, the initialization mode fills the memory by the amount specified in the counter register, FCNT, before the ...

Page 21

Freescale Semiconductor, Inc. 6.1 Software Installation and Concepts Create a directory for the software (for example, extract the software into the DSP56307 , , and efcop_fir efcop_firlms and , as represented in Figure 10. out tvecs DSP56307 Figure 10. Directory ...

Page 22

Freescale Semiconductor, Inc. Application Examples key steps involved in performing an FIR filtering task are described in the following subsections, and a 100 sample signal with a 20 tap FIR filter is used in the example code. The State Initialization ...

Page 23

Freescale Semiconductor, Inc. Initialize FCM Set up DMA 0 for transferring samples to the FDIR Set up DMA 1 for transferring samples from FDOR Initialize EFCOP Read input data from file Enable EFCOP Enable DMA 0 and DMA 1 Perform ...

Page 24

Freescale Semiconductor, Inc. Application Examples After writing the filter coefficients to FCM, setting up DMA channels 0 and 1 for data transfer to/from the EFCOP, and initializing the EFCOP itself, the program reads the input data from the file, and ...

Page 25

Freescale Semiconductor, Inc. 6.3.2 Implementation The implementation of an LMS adaptive FIR filter on the EFCOP requires the steps shown in Figure 14, summarized as: • Filtering of x(k) to produce y(k). This is identical to the fixed FIR filtering ...

Page 26

Freescale Semiconductor, Inc. Application Examples Main program flow Start Initialize EFCOP Initialize FCM & FDM Read x(n) and d(n) signals from files Set up DMA 0 for transferring x(n) samples to FDIR Unmask interrupts Enable EFCOP Enable DMA 0 Perform ...

Page 27

Freescale Semiconductor, Inc. 6.4 Residu Function from the GSM EFR/AMR Vocoders To illustrate the use of the EFCOP in a vocoder environment, this section describes the implementation of the Residu() function from the GSM EFR and AMR transcoders. described in ...

Page 28

Freescale Semiconductor, Inc. Application Examples (#ifdef DSP_CORE) Set Up For Core Code Enable saturation and Two’s Complement Rounding Initialize Coefficients Perform Residu on the DSP56300 Core No All Subframes processed? Yes End Figure 15. Processing Steps Performed by Run_resu.c. Programming ...

Page 29

Freescale Semiconductor, Inc. Finally, to maintain bit-exactness with the ETSI standards, saturation and two’s complement rounding must be set. For the EFCOP, this is achieved by setting the Filter Rounding mode and the Filter Saturation mode. For the DSP56300 core, ...

Page 30

Freescale Semiconductor, Inc. Code Listing for FIR Filtering Example Appendix A Code Listing for FIR Filtering Example /********************************************************************* * * FILENAME: fir DESCRIPTION: FIR filtering using DSP56307 EFCOP PROJECT: fir.pjt * * COPYRIGHT: MOTOROLA 1999. * ...

Page 31

Freescale Semiconductor, Inc. _fract _X output[INPUT_LENGTH - FIR_LENGTH + 1]; void main() { FILE *fp_in, *fp_out; unsigned int i; /* ---------------------------------- * * Initialize EFCOP * ---------------------------------- */ FCSR.B.FEN = 0; /* Disable EFCOP for initialization */ /* Filter Count ...

Page 32

Freescale Semiconductor, Inc. Code Listing for FIR Filtering Example /* FSCO = 0 (No shared coefficients) /* FPRC = 0 (State Initialization) /* FMLC = 0 (Single Channel Mode) /* FOM = 00 (Real FIR Filtering Mode) /* FUPD = ...

Page 33

Freescale Semiconductor, Inc. /* Open input file */ if ((fp_in = fopen("tvecs\\input.txt", "r")) == NULL) { printf ("Error -- Can’t open \"tvecs\\input.txt\"\n"); exit(1 Open output file */ if ((fp_out = fopen("out\\output.txt", "w")) == NULL) { printf ("Error -- ...

Page 34

Freescale Semiconductor, Inc. Code Listing for FIR Filtering Example DDR0 = (int*)&FDIR; /* DMA Offset Regsiter 0 */ DOR0 = 1; /* Offset = DMA Ch0 Control Register */ DCR0.I = 0x14AA04 ...

Page 35

Freescale Semiconductor, Inc. /* DPR = 10 (Priority = 2) /* DCON = 0 (Continuous mode not needed /* DRS = 10110 (DMA Request is MDRQ12: EFCOP FDOBF D3D = 0 (Disable 3D mode) /* DAM = 101100 ...

Page 36

Freescale Semiconductor, Inc. Code Listing for FIR Filtering Example if (FCSR.B.FCONT != 0) { printf("%s%s%s", "\nFCONT = 1\n", "(Contention between EFCOP and Core occurred).\n", "No output written to file.\n"); } else { /* Write output data to file */ for ...

Page 37

Freescale Semiconductor, Inc. Appendix B Code Listing for FIR LMS Example /********************************************************************* * * FILENAME: firlms DESCRIPTION: FIR LMS adaptive filtering using DSP56307 EFCOP PROJECT: firlms.pjt * * COPYRIGHT: MOTOROLA 1999 NOTES: 1) DMA ...

Page 38

Freescale Semiconductor, Inc. Code Listing for FIR LMS Example _fract _X x[INPUT_LENGTH];/* Input signal _fract _X d[INPUT_LENGTH];/* Desired signal _fract _X y[INPUT_LENGTH];/* Filter output signal _fract _X e[INPUT_LENGTH];/* Error signal _fract _X *d_ptr=d;/* Pointer to desired signal _fract _X *y_ptr=y;/* ...

Page 39

Freescale Semiconductor, Inc void main() { FILE *fp1, *fp2, *fp3; unsigned int i; /* ---------------------------------- * * Initialize EFCOP * ---------------------------------- */ FCSR.B.FEN = 0; /* Disable EFCOP for initialization */ /* Filter Count Register */ FCNT = ...

Page 40

Freescale Semiconductor, Inc. Code Listing for FIR LMS Example FCSR.I = 0x000884; /* FDOIE = 1 (Enable Filter Data Out Interrupt FDIIE = 0 (No Filter Data Input Interrupt) /* FSCO = 0 (No shared coefficients) /* FPRC ...

Page 41

Freescale Semiconductor, Inc. exit(1 fclose(fp1); /* ----------------------------------------------- * * Read "desired signal" from file * ----------------------------------------------- */ /* Open "desired signal" file */ if ((fp1 = fopen("tvecs\\d.txt", "r")) == NULL) { printf ("Error -- Can’t open \"tvecs\\d.txt\"\n"); exit(1); ...

Page 42

Freescale Semiconductor, Inc. Code Listing for FIR LMS Example /* DMA Offset Regsiter 0 */ DOR0 = 1; /* Offset = DMA Ch0 Control Register */ DCR0.I = 0x14AA04 DIE = 0 ...

Page 43

Freescale Semiconductor, Inc. /* Other processing tasks are here */ /* -------------------------------------------------- * * Wait for filtering to finish * -------------------------------------------------- */ while (FCSR.B.FDOIE == Wait here until all samples have been processed (when count=0 in lms_isr, ...

Page 44

Freescale Semiconductor, Inc. Code Listing for FIR LMS Example * contention between the EFCOP and the core, the above * checking of FCONT can be omitted ------------------------------------------------------------- */ if (FCSR.B.FCONT != 0) { printf("%s%s%s", "\nFCONT = 1\n", "(Contention ...

Page 45

Freescale Semiconductor, Inc. Appendix C Code Listing for Residu Example /********************************************************************* * * FILENAME: run_resu DESCRIPTION: Test harness for running GSM EFR Residu() on both * the core and on the EFCOP PROJECT: residu.pjt * * ...

Page 46

Freescale Semiconductor, Inc. Code Listing for Residu Example (Located above 4K, as specified in "efcopdma.dsc") */ _fract _X coeffs_X[M+1]; _fract _Y coeffs_Y[M+1]; _fract _X input[L_SUBFR+M]; _fract _X core_output[L_SUBFR]; _fract _X efcop_output[L_SUBFR]; /*** Global variables ***/ unsigned int subframe_count=0; void main() ...

Page 47

Freescale Semiconductor, Inc. if ((fp_efcop_out = fopen("out\\efcop_24.cod", "wb")) == NULL) { printf ("Error -- Can’t open EFCOP output file \"out\\efcop_24.cod\""); printf ("\nProgram Aborted.\n"); exit(1); } #ifdef DSP_CORE /* Set core ALU Saturation Mode and Rounding Mode */ _asm("bset #20,SR");/* Saturation ...

Page 48

Freescale Semiconductor, Inc. Code Listing for Residu Example /* DMA Counter 0: transfer items (counter mode B) */ _asm("movep #$018001,x:$FFFFED"); /* Source address = start of input data buffer */ DSR0 = (int*)input; /* DMA destination ...

Page 49

Freescale Semiconductor, Inc. /* Set up the DMA Control Register for Channel 1 */ DDR1 = (int*)efcop_output; /* DMA Ch1 Control Register */ _asm("movep #$8EB2C1,x:$FFFFE8"); /* DIE = 0 /* DTM = 001 /* DPR = ...

Page 50

Freescale Semiconductor, Inc. Code Listing for Residu Example /* FSM /* FRM /* FSCL = 01 (Scaling of output data: Scale << match C code implementation FDCH.I = 0x000000 decimation; One channel. FCNT = ...

Page 51

Freescale Semiconductor, Inc. /*** To Perform the same calculation on the core... ***/ /*** Call Residu() on core ***/ Residu(&coeffs_Y[0], &input[M], &core_output[0], (int)L_SUBFR); #endif /*** Check to make sure EFCOP has finished. (It will have!!) ***/ while(DSTR.B.DTD1 == 0) {} ...

Page 52

... Motorola Japan Ltd. SPS, Technical Information Center 3-20-1, Minami-Azabu, Minato-ku Tokyo 106-8573 Japan 81-3-3440-3569 ASIA/PACIFIC Motorola Semiconductors H.K. Ltd. Silicon Harbour Centre 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong 852-26668334 Go to: www.freescale.com Home Page http://www.mot.com/SPS/DSP DSP Helpline http://www.motorola-dsp.com/contact email: dsphelp@dsp.sps.mot.com AN2108/D ...

Related keywords