This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Timing on assembly delay loop

I've a simple flash utility which is downlaoded via USB at bootup and I want to verify the flash timing delays between commands to make sure we are waiting long enough. 

The code is unfortunately a loop in assembly. Yech!!

This code will run in internal memory. However I cant find references to instructions for the OMAP35x. Could someone tell me given a fixed clock frequency , how many clock cycles are executed for this loop. 

Note this is single thread execution (based on x-loader) so it will run uninterupted to completion. 

/*******************************************************

* Routine: delay
* Description: spinning delay to use before udelay works
******************************************************/
static inline void delay (unsigned long loops)
{
__asm__ volatile ("1:\n"
"subs %0, %0, #1\n"
"bne 1b":"=r" (loops):"0" (loops));
}

  • Hi Steve,

    As you note the time for executing of delay function depends on cpu frequency. I suggest you a possible way for answering your question.

    There is an assembler dump of delay function:

    arm-none-linux-gnueabi-objdump -D --start-address=0x0 --stop-address=0xc ./board/omap3evm/omap3evm.o

    00000000 <delay>:
           0:    e2500001     subs    r0, r0, #1
           4:    1afffffd     bne    0 <delay>
           8:    e12fff1e     bx    lr

    ............

    Therefore the delay parameter represents to 2 cpu clock cycles. The whole time for executing the delay function corresponds to 2 * delay + 1 clock cycles.

    BR

    Tsvetolin Shulev