9.2.23 SLEEP Macro
A macro that puts the device into sleep mode.
Include
<xc.h>
Prototype
void SLEEP(void);
Remarks
This macro executes a sleep
instruction.
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
}
}