简体   繁体   中英

How to delay one clock cycle in STM32?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM