9.2.19 NOP Macro

A macro that performs no operation.

Include

<xc.h>

Prototype

void NOP(void);

Remarks

This macro executes a nop instruction. A nop instruction can be used, for example, to introduce a small delay, to ensure safe execution of code when the device is in a certain state, or as a convenient place to attach a breakpoint for debugging purposes.

Example

#include <xc.h>

void main(void) {
  SYSTEM_Initialize();

  INTERRUPT_GlobalInterruptEnable();
  WeatherStation_initialize();

  while (1) {
    if (tmr1_tick == 1) {
      WeatherStation_Print();
      tmr1_tick = 0;
    }
    SLEEP(); // wait for interrupt
    NOP();   // ensure instruction pre-fetched while sleeping is safe to execute on awakening
  }
}