Hello,
I'm working with TMS570 MCU at now moment and can't understand one point.
I've created one small function which is necessary to delay necessary count of CPU clocks:
void Wait(uint32_t lVal) { asm(" LSR r0, r0, #1"); asm("LoopLabel:"); asm(" SUBS r0, r0, #1"); asm(" BNE LoopLabel"); }
I expected that loop takes 2 CPU cycles taking into account Cortex™-R5 and Cortex-R5F Technical Reference Manual.
1 cycle for 'SUB' and 1 for 'B'.
So, shift is used to divide input cycles count by 2.
Unfortunately this loop takes 4 cycles. I checked it by debugger (clocks for run between start of loop and end of loop):
Additionaly I checked it by GPIO toggling with input value for the function 0xFFFFFFFF.
With CPU frequence 300MHz it should takes about 0xFFFFFFFF/330000000 = 14sec. But during program run it takes about 28 seconds.
So, why this loop takes 4 cycles?
Thanks a lot in advance for your help.