5.1 __delay_cycles Intrinsic Function

The IAR __delay_cycles intrinsic function adds code which delays execution by the specified constant number of cycles.

Suggested Replacement

There is no equivalent built-in function, but there are library routines that perform a similar task.

Use either the _delay_ms() or _delay_us() functions, specifying the delay time as a double argument.

Caveats

The macro F_CPU should be defined as a constant that specifies the CPU clock frequency (in Hertz). The compiler optimizers must be enabled for accurate delay times.

Examples

Consider migrating IAR code such as:
__delay_cycles(100);
to MPLAB XC8 code similar to:
#define F_CPU 1000000UL
_delay_us(100);

Further Information

See the Library Functions section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on these functions.