Hi,
Using C code is hard to calculate the code execute time.
It need to check the assembly instruction of below code:
for (i = 0U; i < d; ++i)
{
__asm("NOP");
}
For example, we setting to get 1us delay with execute (d = SOURCE_CLOCK / 1000000 * 1) times of "NOP" instruction.
While, the for loop also take time to calculate i variable value and compare with d value.
That's why we use timer to set delay and could get accuracy time interval.
Have a great day,
Mike
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------