9.2.22 RESET Macro

A macro that resets the device.

Include

<xc.h>

Prototype

void RESET(void);

Remarks

Where possible, this macro executes a reset instruction. For devices that do not implement this instruction, this macro puts down some form of jump instruction whose destination is itself. For a Reset to then occur, ensure the watchdog timer is enabled and wait for that to expire. Check your device data sheet to see if the reset instruction is implemented by your device.

Example

#include <xc.h>

void main(void) {
  SYSTEM_Initialize();
  DISP_Initialize();
    
  INTERRUPT_GlobalInterruptEnable();

  while (1) {
    if(DISP_needsUpdate) {
      if(DISP_update() == 0)
        RESET();  // something's gone horribly wrong
    }
  }
}