Skip to main content
Vasile Guta_Ciucur
Senior
October 30, 2017
Solved

How many nanoseconds a NOP consumes at 32MHz stm32L152re?

  • October 30, 2017
  • 4 replies
  • 1140 views
Posted on October 30, 2017 at 01:05

Thank you in advance!

    This topic has been closed for replies.
    Best answer by RomainR.
    Posted on October 30, 2017 at 13:15

    Hello,

    It takes 1 cpu cycle count. maybe 31,25ns. See 

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/CHDDIGAC.html

     

    Also the assembler generates alternative instruction which does nothing, such mov r0, r0

    Regards

    4 replies

    Tesla DeLorean
    Guru
    October 30, 2017
    Posted on October 30, 2017 at 02:10

    You can measure instruction cycles with DWT_CYCCNT

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Vasile Guta_Ciucur
    Senior
    October 30, 2017
    Posted on October 30, 2017 at 11:59

    Ah, something like this:

    uint32_t cycles = 0;
    /* DWT struct is defined inside the core_cm4.h file */
    DWT->CTRL |= 1 ; // enable the counter
    DWT->CYCCNT = 0; // reset the counter
    delayUS(1); // <-- here my Nop()
    cycles = DWT->CYCCNT;
    cycles--; /* We subtract the cycle used to transfer 
     CYCCNT content to cycles variable */�?�?�?�?�?�?�?�?�?

    Carmine Noviello tutorial

    https://www.carminenoviello.com/2015/09/04/precisely-measure-microseconds-stm32/

    RomainR.
    RomainR.Best answer
    ST Employee
    October 30, 2017
    Posted on October 30, 2017 at 13:15

    Hello,

    It takes 1 cpu cycle count. maybe 31,25ns. See 

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/CHDDIGAC.html

     

    Also the assembler generates alternative instruction which does nothing, such mov r0, r0

    Regards

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.