DSPRelated.com
Forums

Problem with DMA

Started by Giovanni Parodi July 4, 2003
Hi Cx,
I have a little problem with DMA in c6701. I need to initialize with 0.0 an
array of 65536 float stored in external memory and I wanna do this operation
using DMA. I created a little program to test the DMA and I've seen that it
works but profiling the function I've seen results not very good. Indeed
the function that use the DMA is faster that old_fill (see code in
dma_func.c) but the difference is only 10%. So I don't understand if I've
done an error in my program or it's all ok. Can you help me ? Is there a
faster method to do the same operation? It's very important for me because
filling the array is an operation time consuming in my project

_________________________________________________________________
Invia messaggi istantanei gratuitamente! http://www.msn.it/messenger/


#include <stdio.h>
#include <stdlib.h>
#include <dma.h>
#include <intr.h>

#define array_size 400
#define big_array_size 65536

unsigned char source[array_size];
unsigned char destination[array_size];
float source2[256];
float destination2[big_array_size];
#pragma DATA_SECTION (source, ".Img_sect")
#pragma DATA_SECTION (destination, ".bss")
#pragma DATA_SECTION (destination2, ".Img_sect")
#pragma DATA_ALIGN(destination2,sizeof(float))
/*
.Img_sect is placed in external memory,see lnk.cmd
*/

/****************************************************************************/

void old_fill(float* dest)
{
int i=0;
for(i=0;i<big_array_size;i++)
dest[i]=0.67;
} /****************************************************************************/

int fill_block(float *src, float *dest, int numBytes, int chan)
{
unsigned int dma_pri_ctrl=0;
unsigned int dma_tcnt=0;
volatile unsigned int far *counter= (unsigned int
*)(DMA_XFER_COUNTER_ADDR(chan));
volatile unsigned int far *GBLIDXA=(unsigned int *)0x01840030;
volatile unsigned int far *GBLCNTA;

GBLCNTA= (unsigned int *)0x01840028;

*GBLIDXA=0xFC040004;
*GBLCNTA=0x00000100;
dma_pri_ctrl = 0x01000073;

dma_tcnt = 0x01000100; /* 256 frames and 256 elements in frame */ /* Write to DMA channel configuration registers */
dma_init(chan,
dma_pri_ctrl,
0,
(unsigned int) src,
(unsigned int) dest,
dma_tcnt);

DMA_START(chan);

while((((*counter)&(0xFFFF))!=0)||(((*counter)&(0xFFFF0000))!=0));

return(1);
}

/****************************************************************************/

int main( )
{
int i=0;

for(i=0;i<256;i++)
source2[i]=0.0;

old_fill(destination2);

fill_block(source2,destination2,big_array_size*sizeof(float), 0);

return 1;
}



Attachment (not stored)
LNK.CMD
Type: application/octet-stream


Hi, Giovanni Parodi,

No matter you use DMA or CPU to initialize an 65536 float array with 0.0 you
need 65536 operations on external memory(surely it was done by DMA). The speed
mostly depend on the configuration of your EMIF(while this is depend on the time
order of your external memory): the setup time, strobe time and the hold time.

Perhaps you can get a fast initialization using CPU. In a extremly position you
can do a memory operation in 1 cycle(internal data ram), then using the two
store channel you can do the initialization in 32768 cycles:

stw .d1 a0, *a1++
||stw .d2 a0, *b1++

If you only need to initialize the array in the beginning of your program you
can use "fill=0" directive in your command file.

Tao Wang
ShangHai, China

----- Original Message -----
From: "Giovanni Parodi" <>
Date: Fri, 04 Jul 2003 07:52:17 +0000
To:
Subject: [c6x] Problem with DMA

Re: Hi Cx,
Re: I have a little problem with DMA in c6701. I need to initialize with 0.0 an
Re: array of 65536 float stored in external memory and I wanna do this operation

Re: using DMA. I created a little program to test the DMA and I've seen that it
Re: works but profiling the function I've seen results not very good. Indeed
Re: the function that use the DMA is faster that old_fill (see code in
Re: dma_func.c) but the difference is only 10%. So I don't understand if I've
Re: done an error in my program or it's all ok. Can you help me ? Is there a
Re: faster method to do the same operation? It's very important for me because
Re: filling the array is an operation time consuming in my project
Re:
Re: _________________________________________________________________
Re: Invia messaggi istantanei gratuitamente! http://www.msn.it/messenger/
Re:
Re: _____________________________________
Re: Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.
Re:
Re: _____________________________________
Re: About this discussion group:
Re:
Re: To Join: Send an email to
Re:
Re: To Post: Send an email to
Re:
Re: To Leave: Send an email to
Re:
Re: Archives: http://www.yahoogroups.com/group/c6x
Re:
Re: Other Groups: http://www.dsprelated.com
Re:
Re:
Re: ">http://docs.yahoo.com/info/terms/
Re:

Re:
Re: #include <stdio.h>
Re: #include <stdlib.h>
Re: #include <dma.h>
Re: #include <intr.h>
Re:
Re: #define array_size 400
Re: #define big_array_size 65536
Re:
Re: unsigned char source[array_size];
Re: unsigned char destination[array_size];
Re: float source2[256];
Re: float destination2[big_array_size];
Re: #pragma DATA_SECTION (source, ".Img_sect")
Re: #pragma DATA_SECTION (destination, ".bss")
Re: #pragma DATA_SECTION (destination2, ".Img_sect")
Re: #pragma DATA_ALIGN(destination2,sizeof(float))
Re: /*
Re: .Img_sect is placed in external memory,see lnk.cmd
Re: */
Re:
Re:
/****************************************************************************/
Re:
Re: void old_fill(float* dest)
Re: {
Re: int i=0;
Re: for(i=0;i<big_array_size;i++)
Re: dest[i]=0.67;
Re: }
Re:
Re:
Re:
/****************************************************************************/
Re:
Re: int fill_block(float *src, float *dest, int numBytes, int chan)
Re: {
Re: unsigned int dma_pri_ctrl=0;
Re: unsigned int dma_tcnt=0;
Re: volatile unsigned int far *counter= (unsigned int
Re: *)(DMA_XFER_COUNTER_ADDR(chan));
Re: volatile unsigned int far *GBLIDXA=(unsigned int *)0x01840030;
Re: volatile unsigned int far *GBLCNTA;
Re:
Re: GBLCNTA= (unsigned int *)0x01840028;
Re:
Re: *GBLIDXA=0xFC040004;
Re: *GBLCNTA=0x00000100;
Re: dma_pri_ctrl = 0x01000073;
Re:
Re: dma_tcnt = 0x01000100; /* 256 frames and 256 elements in frame */
Re:
Re:
Re: /* Write to DMA channel configuration registers */
Re: dma_init(chan,
Re: dma_pri_ctrl,
Re: 0,
Re: (unsigned int) src,
Re: (unsigned int) dest,
Re: dma_tcnt);
Re:
Re: DMA_START(chan);
Re:
Re: while((((*counter)&(0xFFFF))!=0)||(((*counter)&(0xFFFF0000))!=0));
Re:
Re: return(1);
Re: }
Re:
Re:
/****************************************************************************/
Re:
Re: int main( )
Re: {
Re: int i=0;
Re:
Re: for(i=0;i<256;i++)
Re: source2[i]=0.0;
Re:
Re: old_fill(destination2);
Re:
Re: fill_block(source2,destination2,big_array_size*sizeof(float), 0);
Re:
Re: return 1;
Re: }
Re:
<< LNK.CMD >>

--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers