cancel
Showing results for 
Search instead for 
Did you mean: 

memcpy() function

matic
Associate III
Posted on November 06, 2015 at 19:58

Hi there.

I read an article about copying data using CPU (''for'' loop) and DMA (Mem2Mem).

http://www.embedds.com/using-direct-memory-access-dma-in-stm23-projects/

Below in the comments of that article is described also an approach, which uses memcpy() function. Interestingly, this is also (much) faster than DMA. I never used memcpy() function, so I would like to ask, how could it be faster than DMA? As long as it is a function, I suppose it occupy CPU? But how it works? Where can I see its definition?

Thanks

#memcpy
2 REPLIES 2
Posted on November 06, 2015 at 21:09

You'd get yourself the library source, or disassemble it.

The memcpy doesn't have any setup overhead, the memory is tightly coupled and the processor has write-buffers. You'd have to dig into the gate-level implementation, but I suspect the DMA state-machine has more states, and has to arbitrate/request access from the core.

One of the typical memcpy() optimizations is reading multiple words, and then writing multiple words. DMA would have a single holding register

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
matic
Associate III
Posted on November 06, 2015 at 22:32

Do you have maybe an example code to see how it is used?