Sleep & Power managed modes can be a little confusing.
With IDLEN = 0 the SLEEP instruction shuts down everything except for the watchdog timer if it's enabled. This stops all internal clocks by stopping the main oscillator. The internal 31kHz that the WDT uses is still operating so the WDT can timeout and wake it from sleep.
PRI_RUN, SEC_RUN, and RC_RUN are the only 3 modes that don't require execution of the SLEEP command to enter.
These are selected by changing bits in the OSCCON register. These modes let you change the oscillator. SEC_RUN would switch to the oscillator on Timer1.
This keeps everything running, but on the lower power osc that's connected to the Timer1 osc pins.
RC_RUN switches to the internal RC oscillator. Both can consume less power than most external crystals. PRI_RUN operates from whatever oscillator you have selected in config.
The IDLE modes PRI_IDLE, SEC_IDLE, and RC_IDLE are entered by setting the IDLEN bit, then selecting the oscillator with OSCCON bits 1,0 then executing the SLEEP instruction. If you already have the oscillator selected for the idle mode you want, then just setting IDLEN before executing the SLEEP instruction is all that's required.
IDLE modes just put the CPU to sleep, but keep clocks available for all peripherals.
SEC_IDLE or RC_IDLE would normally be the lowest power options. It would run all peripherals from the LP oscillator on Timer1, or the internal RC oscillator "set for 31kHz".
Look in the Electrical Characteristics section of the datasheet under Power-Down and Supply Current for various modes & power consumption.
The key is the IDLEN bit. When this bit is clear, it doesn't matter what oscillator or mode is selected. The execution of a SLEEP instruction will shut everything down except for the WDT if enabled.
When the IDLEN bit is set, and the SLEEP instruction is executed, then it enters one of the 3 IDLE modes with the CPU shut down, and peripheral clocks provided by whatever osc you have selected in OSCCON bits 1,0.
Bookmarks