/* * ======== My lab02.c ======== */ /* * ======== Include files ======== */ #include // C6000 compiler definitions #include #include #include #include #include #include #include "lab02cfg.h" #include "coeff.h" /* * ======== Prototypes ======== */ void initEmif(void); void initEdma(void); void initHwi(void); extern void blockSine(short *buf, int len); void edmaHwi(void); void FIRfilter(int *inbuf, int *outbuf, float *coeff, int buffSize, int Norder); void processBuffer(void); // 6-16 /* * ======== Declarations ======== */ #define PING 0 // 5-10 #define PONG 1 // 5-10 #define BUFFSIZE 256 /* * ======== Global Variables ======== */ int gBufferXmtPing[BUFFSIZE]; // 5-10 int gBufferXmtPong[BUFFSIZE]; int gBufferRcvPing[BUFFSIZE]; int gBufferRcvPong[BUFFSIZE]; #pragma DATA_SECTION(gDelay, ".far"); #define gDELAYSIZE 12000 int gDelay[gDELAYSIZE]; int gIndex=0; EDMA_Handle hEdmaXmt; EDMA_Handle hEdmaReloadXmtPing; // 3-23 EDMA_Handle hEdmaReloadXmtPong; // 5-10 EDMA_Handle hEdmaRcv; EDMA_Handle hEdmaReloadRcvPing; // 3-23 EDMA_Handle hEdmaReloadRcvPong; // 5-10 short gXmtChan; short gRcvChan; // 4-16 /**************************************************************\ * The "EDMA Config" type data structure holds the * parameters to be programmed into a EDMA channel. * Register Make (RMK) macros build a 32-bit unsigned int; * below it is used to build the Options (OPT) register. * The OF macros provide the proper typecasting needed for * the EDMA Config data structure. * * To locate the structure below, use: * * Help-->User Manuals--> * SPRU401 - TMS320C6000 Chip Support Library API Reference Guide * * 1. Open the SPRU401 .pdf file. * 2. Search for "EDMA_OPT_field_symval" and go to the link * * Notice that Table B-23 specifies how to build the * OPT RMK structure. If you want to know the options for * each field, just look at the table. * * You can locate the other Config fields by searching for: * * "EDMA_SRC_field_symval" \**************************************************************/ EDMA_Config gEdmaConfigXmt = { // 3-12 EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, // Priority? // EDMA_OPT_ESIZE_16BIT, // Element size? EDMA_OPT_ESIZE_32BIT, // Element size? EDMA_OPT_2DS_NO, // 2 dimensional source? EDMA_OPT_SUM_INC, // Src update mode? EDMA_OPT_2DD_NO, // 2 dimensional dest? EDMA_OPT_DUM_NONE, // Dest update mode? 4-16 EDMA_OPT_TCINT_YES, // Cause EDMA interrupt? EDMA_OPT_TCC_OF(0),// Transfer complete code? EDMA_OPT_LINK_YES, // Enable link parameters? EDMA_OPT_FS_NO // Use frame sync? 4-16 ), EDMA_SRC_OF(gBufferXmtPing), // src address? 5-10 EDMA_CNT_OF(BUFFSIZE), // Count = buffer size EDMA_DST_OF(0), // dest address? 4-16 EDMA_IDX_OF(0), // frame/element index value? EDMA_RLD_OF(0) // reload }; EDMA_Config gEdmaConfigRcv = { // 4-16 EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, // Priority? // EDMA_OPT_ESIZE_16BIT, // Element size? EDMA_OPT_ESIZE_32BIT, // Element size? EDMA_OPT_2DS_NO, // 2 dimensional source? EDMA_OPT_SUM_NONE, // Src update mode? 4-16 EDMA_OPT_2DD_NO, // 2 dimensional dest? EDMA_OPT_DUM_INC, // Dest update mode? 4-16 EDMA_OPT_TCINT_YES, // Cause EDMA interrupt? EDMA_OPT_TCC_OF(0),// Transfer complete code? EDMA_OPT_LINK_YES, // Enable link parameters? EDMA_OPT_FS_NO // Use frame sync? 4-16 ), EDMA_SRC_OF(0), // src address? EDMA_CNT_OF(BUFFSIZE), // Count = buffer size EDMA_DST_OF(gBufferRcvPing), // dest address? 4-16, 5-10 EDMA_IDX_OF(0), // frame/element index value? EDMA_RLD_OF(0) // reload }; /* * ======== main ======== */ void main() { int i; initEmif(); // Dummy function - see note below for(i=0; i>16); rtmp = (short) _abs(gBufferRcvPing[i]); lmax = lmax= 0;i--) x[i]=x[i-1]; x[0] = floatsamp; sum = 0.0; for(i=0; i<=Norder; i++) /* Perform FIR filtering (convolution) */ sum=sum+x[i]*coeff[i]; intsamp = ((int) sum) & 0xffff; /* Convert result back to integer form. */ outbuf[j] = intsamp << 16 | intsamp; /* Send to buffer (both channels ) */ } }