5

The datasheet of my PIC16 refers to the "SLEEP instruction". I'm programming the PIC16 in C using MPLAB X and the XC8 compiler.

How can I execute a SLEEP instruction on my PIC16 using C?

Randomblue
  • 11,003
  • 31
  • 106
  • 178

1 Answers1

9

You can use this macro:

SLEEP();  

This macro is used to put the device into a low-power standby mode.

If you search for the definition of SLEEP() in the header files, you'll find:

#define SLEEP()     asm("sleep")

asm(); is a statement which allows you to inline assembly instructions into your C code.

m.Alin
  • 10,738
  • 19
  • 63
  • 89