DSPRelated.com
Forums

Error in DM642 DTA copy

Started by ssk3666 September 11, 2009
Hi, All.

I'm using DM642 to do some image process. I opened two tasks. One is for capture image, the other is for image process, when I want to copy data frome one task to another, I find the data after copy is totally different. Here is my code.

In task caputer:
#pragma DATA_ALIGN(128)
static char buffer[2 * FF_WIDTH * FF_HEIGHT];
void TaskSendSerialData()
{
char *pBuffer = buffer;
......
msg1.cDst = TSK_ACADJUST;
msg1.cSrc = TSK_GETIMAGE;
msg1.pData = pBuffer;
MBX_post(hMbxAutoAdjust, &msg1, 0);
......
}

In task process:
#pragma DATA_ALIGN(128)
static char pYuvBuf[FF_WIDTH * FF_HEIGHT * 2];
void TaskImageProcess()
{
......
MBX_pend(hMbxAutoAdjust, &msg, SYS_FOREVER);
img = *(IMAGE_INFO *)msg.pData; //this is a struct for image info
pSrc = msg.pData + sizeof(IMAGE_INFO);
pDst = pYuvBuf;
for(i = 0; i< img.nHeight * 2; i++)
{
CACHE_clean(CACHE_L2, pYuvBuf, img.nWidth>> 2);
dma_id = DAT_copy(pSrc, pYuvBuf, img.nWidth);
pSrc += img.nWidth;
pDst += img.nWidth;
DAT_wait(dma_id);
//DAT_wait(DAT_XFRID_WAITALL);
}
DAT_wait(DAT_XFRID_WAITALL);
......
}

I found out that the addr of data is correctly passed, it seems that the problem lies on DAT copy.

I used little endian, please tell me where is wrong for my code, thx very much!!!!

_____________________________________
ssk,

A few minutes on the debugger would point out that the line
CACHE_clean(CACHE_L2, pYuvBuf, img.nWidth>> 2);
(because the pYuvBuf is the incorrect variable to use, it should be pDst)
is always cleaning the same area of L2, rather than the next area to be written to.

A few more minutes on the debugger would point out that the line
dma_id = DAT_copy(pSrc, pYuvBuf, img.nWidth);
(because the pYuvBuf is the incorrect variable to use, it should be pDst)
is always writing to the same area of L2, rather than the next area to be written to.

I'm also a bit vague as to why the size of the area being used in the call to CACHE_clean is only 1/4th the
size of the area to be written to. Maybe something to do with words. vs. bytes??
And, if it is words .vs. bytes, then there is a constraint that nWidth must be a multiple of 4.

R. Williams

---------- Original Message -----------
From: "ssk3666"
To: c...
Sent: Fri, 11 Sep 2009 02:54:48 -0000
Subject: [c6x] Error in DM642 DTA copy

>
>
> Hi, All.
>
> I'm using DM642 to do some image process. I opened two tasks. One is for capture image, the other is for image process, when I want to copy data frome one task to another, I find the data after copy is totally different. Here is my code.
>
> In task caputer:
> #pragma DATA_ALIGN(128)
> static char buffer[2 * FF_WIDTH * FF_HEIGHT];
> void TaskSendSerialData()
> {
> char *pBuffer = buffer;
> ......
> msg1.cDst = TSK_ACADJUST;
> msg1.cSrc = TSK_GETIMAGE;
> msg1.pData = pBuffer;
> MBX_post(hMbxAutoAdjust, &msg1, 0);
> ......
> }
>
> In task process:
> #pragma DATA_ALIGN(128)
> static char pYuvBuf[FF_WIDTH * FF_HEIGHT * 2];
> void TaskImageProcess()
> {
> ......
> MBX_pend(hMbxAutoAdjust, &msg, SYS_FOREVER);
> img = *(IMAGE_INFO *)msg.pData; //this is a struct for image info
> pSrc = msg.pData + sizeof(IMAGE_INFO);
> pDst = pYuvBuf;
> for(i = 0; i< img.nHeight * 2; i++)
> {
> CACHE_clean(CACHE_L2, pYuvBuf, img.nWidth>> 2);
> dma_id = DAT_copy(pSrc, pYuvBuf, img.nWidth);
> pSrc += img.nWidth;
> pDst += img.nWidth;
> DAT_wait(dma_id);
> //DAT_wait(DAT_XFRID_WAITALL);
> }
> DAT_wait(DAT_XFRID_WAITALL);
> ......
> }
>
> I found out that the addr of data is correctly passed, it seems that the problem lies on DAT copy.
>
> I used little endian, please tell me where is wrong for my code, thx very much!!!!
------- End of Original Message -------
ssk,

The is also the detail that the line
static char buffer[2 * FF_WIDTH * FF_HEIGHT];
does not allow for the size of the info area (IMAGE_INFO) at the beginning of the image.

Given the three obvious problems, there may be other problems that also need to be discovered and corrected.

R. Williams

---------- Original Message -----------
From: "ssk3666"
To: c...
Sent: Fri, 11 Sep 2009 02:54:48 -0000
Subject: [c6x] Error in DM642 DTA copy

>
>
> Hi, All.
>
> I'm using DM642 to do some image process. I opened two tasks. One is for capture image, the other is for image process, when I want to copy data frome one task to another, I find the data after copy is totally different. Here is my code.
>
> In task caputer:
> #pragma DATA_ALIGN(128)
> static char buffer[2 * FF_WIDTH * FF_HEIGHT];
> void TaskSendSerialData()
> {
> char *pBuffer = buffer;
> ......
> msg1.cDst = TSK_ACADJUST;
> msg1.cSrc = TSK_GETIMAGE;
> msg1.pData = pBuffer;
> MBX_post(hMbxAutoAdjust, &msg1, 0);
> ......
> }
>
> In task process:
> #pragma DATA_ALIGN(128)
> static char pYuvBuf[FF_WIDTH * FF_HEIGHT * 2];
> void TaskImageProcess()
> {
> ......
> MBX_pend(hMbxAutoAdjust, &msg, SYS_FOREVER);
> img = *(IMAGE_INFO *)msg.pData; //this is a struct for image info
> pSrc = msg.pData + sizeof(IMAGE_INFO);
> pDst = pYuvBuf;
> for(i = 0; i< img.nHeight * 2; i++)
> {
> CACHE_clean(CACHE_L2, pYuvBuf, img.nWidth>> 2);
> dma_id = DAT_copy(pSrc, pYuvBuf, img.nWidth);
> pSrc += img.nWidth;
> pDst += img.nWidth;
> DAT_wait(dma_id);
> //DAT_wait(DAT_XFRID_WAITALL);
> }
> DAT_wait(DAT_XFRID_WAITALL);
> ......
> }
>
> I found out that the addr of data is correctly passed, it seems that the problem lies on DAT copy.
>
> I used little endian, please tell me where is wrong for my code, thx very much!!!!
------- End of Original Message -------