AnsweredAssumed Answered

Single bulk memory copy (instead of memcpy)

Question asked by Roy Ben Hayun on May 4, 2018
Latest reply on May 5, 2018 by Clive One

We are using STM32-767ZI and copying a small array into a memory area which is mapped to an external FPGA.

Looking for how to make the copy in a single bulk operation.

 

The options are:

1. with a loop:

        while(i < destMemoryLength){
            destMemoryAddress[i] = srcMemoryBuffer[i];
            i++;
        }

this is probably using the CPU for each copy. (guessing it's an assembly MOV operations for each).

 

2. with C memcpy(dest, src, size):

        memcpy(destMemoryAddress, srcMemoryBuffer, sizeof(srcMemoryBuffer));

        //Q: Is memcpy optimized to use a single CPU instruction, or uses a loop internally?

 

3. Is there another HAL\CMSIS\else command or function that does a bulk copy?

(in other words, what should we do to ensure a bulk copy, and not a byte-by-bye copy?)

 

Thanks!

Outcomes