100% found this document useful (1 vote)
106 views

PIC18F4550 Sleep Mode - PIC Controllers

The PIC18F4550 microcontroller has a sleep mode that allows it to reduce power consumption when idle. To enter sleep mode, the oscillator is turned off to stop system clocks. The microcontroller can enter sleep mode by clearing the IDLEN bit and executing the SLEEP instruction. It can wake from sleep mode via interrupts, reset, or watchdog timer timeout. An example uses an external interrupt to put the PIC18F4550 into sleep mode, stopping an LED from blinking, and wake it to resume blinking.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
106 views

PIC18F4550 Sleep Mode - PIC Controllers

The PIC18F4550 microcontroller has a sleep mode that allows it to reduce power consumption when idle. To enter sleep mode, the oscillator is turned off to stop system clocks. The microcontroller can enter sleep mode by clearing the IDLEN bit and executing the SLEEP instruction. It can wake from sleep mode via interrupts, reset, or watchdog timer timeout. An example uses an external interrupt to put the PIC18F4550 into sleep mode, stopping an LED from blinking, and wake it to resume blinking.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PIC18F4550 Sleep Mode

Introduction
PIC18F4550 has a power-down mode to reduce power consumption when the microcontroller is idle. Most of the applications like
mobile phones, laptops rely on sleep mode which suspends most or all microcontroller operations to minimize power consumption.
Sleep mode is necessary for such applications because these are battery-operated devices which help to consume less energy

               

Concept of Sleep mode

In PIC18F4550 sleep mode, the device oscillator is turned off.

So no system clocks are occurring in the device. This keeps the PIC in a low power consumption state.

Enter PIC18F4550 in Sleep mode


To enter the PIC18F4550 in sleep mode,

1. clear the IDLEN bit in the OSCCON register.

Bit IDLEN:

            0 = enable sleep mode


            1 = enable idle mode

       2. And Execute the SLEEP instruction.

This halts all the clocks and oscillator as shown below

If WDT (Watchdog Timer) is enabled then INTRC Source having a frequency of 31 kHz is enabled.

If the Timer1 oscillator is enabled it will also continue to run.

Wake-up PIC18F4550 from Sleep Mode


PIC18F4550 can wake up from sleep mode by events like

Interrupt
Reset
WDT time out

Interrupts are any interrupt sources like external interrupt, timer interrupt, usart interrupt, ADC interrupt, etc can cause the PIC
microcontroller to exit from sleep mode.

IDLEN bit is not affected by the wake-up which means it will remain as 0.

Example
Let’s develop a simple application in which we force the PIC18F4550 to enter into sleep mode or exit from sleep mode by using an
external interrupt.

Interfacing Diagram
When the PIC microcontroller is in normal mode it will start blinking the LED and by giving external interrupt it will go into
sleep mode and the LED will stop blinking.
When the PIC microcontroller is in sleep mode, after providing external interrupt it will wake up and start blinking the LED
again.

Program
/*

Enter PIC18F4550 in sleep


www.electronicwings.com
and wake-up through external interrupt

*/

#include <pic18f4550.h>

#include "osc_config.h"

#define LED LATD

void MSdelay(unsigned int);

int flag;

void main()

TRISD=0;

TRISBbits.RB0=1; /* Set PORTB.0 as input*/

OSCCON=0x72; /* Internal osc. freq. 8MHz with IDLEN=0,

enabling IDLEN enables sleep mode */

INTCON2=0x00; /* INT0 negative edge interrupt selected */

INTCONbits.INT0IF=0; /* Clear INT0 interrupt flag */

INTCONbits.INT0IE=1; /* Enable INTOIF interrupt */

INTCONbits.GIE=1; /* Enable global interrupt */

flag = 0;

LED = 0; /* Turn OFF led initially */

while(!flag)

LED = ~LED; /* Blink LED continuously */

MSdelay(300);

SLEEP(); /* Enter in sleep mode */

void interrupt ISR()

flag = ~flag;

INTCONbits.INT0IF=0;

void MSdelay(unsigned int val)

unsigned int i,j;

for(i=0;i<val;i++)

for(j=0;j<165;j++);

You might also like