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.

DM648 problem on calling memcpy

Hi, everyone. In my program, there are two tasks(task1 and task2) and one global variable(unsigned char array[3][1920*1080]). In task1, we copy data from the video driver to the array[3][1920*1080], and the data in the array[3][1920*1080] is right. In task2, we copy data from array[3][190*1080] to a local variable(unsigned char array_local[3][1920*1080]) by calling the function memcpy()(memcpy(array_local,array,3*1920*1080)),However, some data in the array_local[3][1920*1080] is wrong. Besides, we use the loop to copy(for(i=0;i<=2;i++) for(j=0;j<=1920*1080-1;j++) array_local[i][j]=array[i][j];)),the result is same with that by calling memcpy(). what causes the failure of data copying, please help me.  Thank you.

  • HI,

    You said that in Task2 you copy data from a global variable to a local variable.  Are you sure that you have enough stack for the local variable?
    How big is your Task2 stack because I wouldn't be surprise that the stack is overflowing.

    Ideally, you want to allocate memory from a heap for this instead of using a local variable and global variables.  Just my 2 cents.

    Judah

  • Thank you for you reply, Judah. the stacksize of task2 is 20*1024*1024. However, if the stacksize is bigger(for example 30*1024*1024), the program run wrong during BIOS_init, because we find the main() function cannot run.