The question is as simple as the topic. How to delay exact one clock cycle in STM32? If the controller runs at 168MHz, is one clock cycle equal to 1/168MHz, which is 5.95ns?
Asked
Active
Viewed 2.6k times
7
-
2It seems like this might provide the answer: http://stackoverflow.com/questions/18220928/processor-instruction-cycle-execution-time – Jason Lewis May 26 '14 at 06:52
-
I just read the thread, thanks! It seems that the processor is running based on a different structure.. – richieqianle May 26 '14 at 07:03
-
What could I do if I need exact timing to communicate with hardwares, such as a very high speed ADC? – richieqianle May 26 '14 at 07:06
1 Answers
12
You can try to use assembly in your C code. Its quite easy with the asm() function. I believe it would look like this:
asm("NOP");
This is just the assembly instruction for 'Don't do anything for this PC tick'. Also you should make sure that your compiler does not optimize it out.

Owl_Prophet
- 362
- 5
- 15