_delay Builtin

A builtin function that delays execution.

Include

<xc.h>

Prototype

void _delay(unsigned long cycles);

Argument

cycles
The number of cycles to delay

Remarks

This is an inbuilt function that is expanded by the code generator. When called, this routine expands to an in-line assembly delay sequence. The sequence will consist of code that delays for the number of instruction cycles that is specified as the argument. The argument must be a constant expression.

The _delay() builtin function can use loops and the nop instruction to implement the delay.

An error will result if the requested delay is not a constant expression or is greater than 50,463,240 instructions. For even larger delays, call this function multiple times.

Example

#include <xc.h>

int main (void)
{
  _delay(10);    // delay for 10 cycles
}