This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Chain tool speed

Hello I'v just ordered a NRF51-DK kit.

I'm looking at the different tool chain. In my application speed is critical 16Mhz is actually bearly enough, so my question is:

-Is there a difference in the execution speed of the same code written : Keil , eclipse GCC, or Mbed?

-I see that the NRF51-DK is actually running at 32Mhz, is this ok to put a 32 Mhz Cristal to a nRF51822??

Thanks

  • I don't think it is a definitive answer for that, except that i believe Mbed would be slower because it is higher level. Both in Keil and GCC you have optimization options:

    gcc.gnu.org/.../Optimize-Options.html

    www.keil.com/.../uv4_dg_adscc.htm

    In Keil you have the -Otime optimization, which will optimize for execution time. But, in the end I believe you just have to test, because it depends on your code.

    You can use a 32MHz crystal, but the chip only runs on 16MHz anyway. It just divides the clock.

  • It's all about how you write your code. Knowing how the compiler generate code and write optimize code would be the latest. One compiler with same setting you can have 2 sets of code with one running faster the the other.

    A simple example

    a = b / 2;  // Takes many cpu cycles
    a = b >> 1; // only 1 cycle
    

    Compiler will not optimize that for you.

    There is a good book on writing optimized code.

    "C++ Footprint and Performance Optimization" by Rene Alexander & Grahm Bensley. Published by SAMS. ISBN 0-672-31904-7

    PS. mBed not recommended for speed.

  • This is also an interesting read regarding optimization. The modulo operator is something embedded engineers fear like the plague, but it's actually efficient on the ARM platform: embeddedgurus.com/.../

    When it comes to speed, it's as Nguyen says, it's the code that the developer writes that has the most impact.

    Doing shift-operations are always efficient compared to doing division/multiplication. I've seen many funky macro functions for effective divisions, which are purely made with regards to speed, and to be accurate enough for the scope it's used in.

    Here's a fantastic snippet from Quake 3 src sqrt calculation: en.wikipedia.org/.../Fast_inverse_square_root

    Cheers, Håkon

Related