Delay function takes the doubel of time

Hello,
I'm using an stm32f103C8 and trying to produce a precise delay funcion.
I'm using a HSE of 72Mhz so a I supposed the clock cycle is equal to 13.8ns.
The delay function is simply a while(count--) where count has the specific number of times for looping to gain the requested time.
I made an hypothese that while(count--) takes 3 cycles to execute.
So when I need to make 1µs delay I put 24 in count.

But I found that I make 4us with count =24 that means 4 times the desired time.
Please can you help identify this problem?

Parents Reply Children
More questions in this forum