AnsweredAssumed Answered

memcpy crash bf 561

Question asked by Ryan_Sommer on Oct 21, 2016
Latest reply on Nov 3, 2016 by Ryan_Sommer

Hello! I have a "funny" situation with a video project on a bf 561.

 

I assigned the L1 memory start address for core a (0xff800000) to a pointer (L1_mem). 

In a function, I am trying to write a certain amount of pixels into where "L1_pointer" points and then reading these pixels from L1 again.

It works fine until I read from L1 for the first time. After calling memcpy once and using the L1 start address as a source pointer, the processor crashes when I call memcpy for the second time. 

The funny thing is, when I tried to printf the pointer address, the code worked! So when I printf a newline after using memcpy once, the code works just fine. So I assume that I need to reset a single bit somewhere which is done by printf, but before trying out every memory control register there is, I thought that one of you might possibly know what to do/not do.

 

Code below, I am very grateful for any tips that might lead to a solution.

 

Ryan

 

//Pixels written into L1

 

short *L1_pointer = L1_mem;
    
    short line_count;
    for(line_count=0; line_count < ceil(line_width/2) ; line_count++){      
        memcpy(L1_pointer, in_address + 142 + pixel_offset,(sizeof(short)) * pixel_width);
        in_address += PIXEL_PER_LINE;
        L1_pointer += (sizeof(short)) * pixel_width;
       }
       
       // Field 2
       in_address = inFrame + PIXEL_PER_LINE * 335 + PIXEL_PER_LINE * (int)ceil(line_offset/2);
       
       for(line_count=0; line_count < ceil(line_width/2) ; line_count++){        
        memcpy(L1_pointer, in_address + 142 + pixel_offset,(sizeof(short)) * pixel_width);
        in_address += PIXEL_PER_LINE;
        L1_pointer += (sizeof(short)) * pixel_width;
       }

 

//Pixels read from L1

 

L1_pointer = L1_mem;   

 

    for(line_count=0; line_count < ceil(line_width/2) ; line_count++){     
        memcpy(out_address + 142 + pixel_offset, L1_pointer,(sizeof(short)) * pixel_width;
        out_address += PIXEL_PER_LINE;
        L1_pointer += (sizeof(short)) * pixel_width;
       }

 

       //Feld 2
       out_address = outFrame + PIXEL_PER_LINE * 335 + PIXEL_PER_LINE * (int)ceil(line_offset/2);
       

       //this is where I accidentally placed the printf that made the code work
       //printf("\n");
       
       for(line_count=0; line_count < ceil(line_width/2); line_count++){      
          memcpy(out_address + 142 + pixel_offset, L1_pointer,(sizeof(short)) * pixel_width);

          out_address += PIXEL_PER_LINE ;
          L1_pointer += (sizeof(short)) * pixel_width;
       }
}

Outcomes