How long is __NOP()
Hello,
How long does the __NOP() function last?
Is it the time of a cycle? Or 1/F = cycle time?
My MCU is an STM32F401RE, and I understand that the maximum frequency is 84 Mhz.
So 1/84 Mhz = 11.90 ns, is that the time of a cycle?
In my case, if I loop 14 times on __NOP(), it takes 1.24us or 1240 ns (measured with an oscilloscope).
But if I do 14 x 11.90 ns, I get 167 ns...
Does anyone have an explanation?
Thank you in advance for your valuable answers
Sincerely, Antoine
Code:
__disable_irq();
for (int i = 0; i < (nLed * (nBytePerLed * nBit8)); i++)
{
int j = 0;
Data = 1;
if (data[i])
{// ONE
for (; j < 8; j++) {__nop();} //......i = 8: 660ns
Data = 0;
for (; j < 14; j++) {__nop();}//......i = 14: 1.24us
}
else
{// ZERO
for (; j < 3; j++) {__nop();}//.......i = 3: 380ns
Data = 0;
for (; j < 13; j++) {__nop();}//......i = 3: 1.20us
}
}
__enable_irq();