This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multi-Task problem with DSP DM6437

Expert 1840 points


Dear experts,

 

I am working with DSP DM6437. The development environment included CCS 3.3, pspdrivers_1_10_03, edma3_lld_1_06_00_01, bios_5_31_02 ...

My project contains 1 idle task (main), and 3 others. 1 of 3 do the main video intelligent processing (VIP) and 2 remained threads used for SPI read / write functions. All of tasks was started correctly but whenever VIP process step into  it's loop with some calculation function, the others Read/Write task was paused (freezed). Whenever the VIP was ended (escape the loop), Read/Write task work again normally. I guess the problem come from the CPU cannot schedule the task correctly to make them work in parallel. Below is my task creation and brief of VIP task. 

    tskAttrs.priority  = 1;
    tskAttrs.stacksize = 4096;
    tskReader = TSK_create ((Fxn)reader, &tskAttrs, spiInHndl);
    if (tskReader == NULL)
    {
       SYS_abort("spi reader task creation failed!\n");
    }
    LOG_printf(&trace, "spi reader created.\n");

    tskAttrs.priority  = 2;
    tskAttrs.stacksize = 4096;
    tskWriter = TSK_create ((Fxn)writer, &tskAttrs, spiOutHndl);
    if (tskWriter == NULL)
    {
       SYS_abort("spi writer task creation failed!\n");
    }

    tskAttrs.stacksize = 16*1024;   
    tskAttrs.priority  = 2;
    if(NULL == (TSK_create((Fxn)mainAIProcess, &tskAttrs, NULL)))
    {
      printf("Error: Can't create the AI processing\n");
    }

 

void mainAIProcess ()
{

...

 while (1)
  {

       ... 

       iStatus = videoCaptureGetFrame (InParams.CcdcHandle, &InBuffers);
       if (0 != iStatus)
       {       
            printf ("%s: Captured failed, error code : %d\r\n", __FUNCTION__, iStatus);
            goto cleanup;
       }             
                                       
       VnSUti8BitDownScaleFromYUV422I((unsigned char*)InBuffers.SwapBuffer->frame.frameBufferPtr, iWidth, iHeight, pUcVCAGrayImage, iVCADownRatio, iVCAWidth);

       ...

  }

}

 

the function VnSUti8BitDownScaleFromYUV422I just extract the Y element from frame and put into another scaled image. I am sure all of the function was tested for the logic and programming errors.

void VnSUti8BitDownScaleFromYUV422I(unsigned char* iPUcOldImage, int iIOldWidth, int iIOldHeight, unsigned char* oPUcNewImage, int iIRatio, int iINewWidth)
{
    int x, y;
    int iMatchPos;   
    unsigned char* iPUcTmpOldImage = iPUcOldImage + 1;
    for(y = 0; y < iIOldHeight; y++)
    {       
        for(x = 0; x < iIOldWidth; x++, iPUcTmpOldImage = iPUcTmpOldImage + 2)
        {
            iMatchPos =  ((int)(y / iIRatio) * iINewWidth) + (int)(x / iIRatio);
            *(oPUcNewImage + iMatchPos) = *iPUcTmpOldImage;                                   
        }
    }
}

Please give me a hand to step over this problem. I am a newbie with this this field.

 

Thank you very much!

p/s: if i comment the VnSUti8BitDownScaleFromYUV422I, all things worked correctly. again I am sure that VnSUti8BitDownScaleFromYUV422I have no problem itself.