Equivalent for NOP in C for Embedded?

AAI picture AAI · Sep 10, 2014 · Viewed 12k times · Source

I use KEIL to compile a program.

The program uses the code

asm("NOP");

Unfortunately KEIL compiler does not accept the statement.

The idea is to introduce a delay by using NOP (no operation) assembly code.

What is the actual equivalent of this in C ? Does this vary with the embedded controller that I use?

Answer

Leeor picture Leeor · Sep 10, 2014

There's an intrinsic nop in most compilers, Keil should have this as well - try __nop()

See - https://www.keil.com/support/man/docs/armcc/armcc_chr1359124998347.htm

Intrinsic functions are usually safer than directly adding assembly code for compatibility reasons.