0
\$\begingroup\$

I have a routine for SHA-1 on a few bytes of input that takes 17ms to complete on a 8051-based core (running at 32Mhz). It calls memcpy once but it seems to be the bottleneck (taking almost the whole of the 17ms!).

Does anyone know if there's a way to improve the performance of memcpy? Thanks

\$\endgroup\$
4
  • \$\begingroup\$ Depends highly on which 8051 variant you use - some have more than one DPTR - and how your C-Lib implements memcpy(). \$\endgroup\$ – Turbo J Oct 31 '15 at 10:45
  • \$\begingroup\$ I believe there's 2 DPTR. It's the core used in the CC2541. \$\endgroup\$ – John M. Oct 31 '15 at 10:58
  • \$\begingroup\$ How many bytes are you memcpying? \$\endgroup\$ – pjc50 Oct 31 '15 at 11:04
  • \$\begingroup\$ The data should be less than 50 bytes. \$\endgroup\$ – John M. Oct 31 '15 at 11:07
1
\$\begingroup\$

First off consider writing your own version of the memcpy() routine to substitute for the library call. You could then experiment with the code to see how changing the types of memory pointers affects the performance.

Secondly you can instrument that routine with a port bit set at the begin and port bit clear at the end. You can the use an oscilloscope to measure the actual time spent in the routine. It seems highly likely that there is something else going on than just the time spent inside the memcpy() routine.

Take a look at the 8051 compiler that you are using. There is a huge difference in performance between a certain free compiler and one of the more widely used commercial compilers. Also not all compilers support multiple data pointers or some #pragma may be needed to turn on their usage.

\$\endgroup\$
1
\$\begingroup\$

The CC2541 has a DMA controller. I suggest using it for XDATA<->XDATA memory copies. Note that this won't work if one memory location is not XDATA (like CDATA or (I)DATA).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.