CHAPTER 2 PIC® Microcontroller Low Power Tips 'N Tricks
Total Page:16
File Type:pdf, Size:1020Kb
PIC® Microcontroller Low Power Tips ‘n Tricks CHAPTER 2 PIC® Microcontroller Low Power Tips ‘n Tricks Table Of Contents TIPS ‘N TRICKS INTRODUCTION Microchip continues to provide innovative products that are smaller, faster, easier to GENERAL LOW POWER TIPS ‘N TRICKS use and more reliable. The Flash-based PIC® TIP #1 Switching Off External Circuits/ microcontrollers (MCUs) are used in an wide Duty Cycle .......................................... 2-2 range of everyday products, from smoke TIP #2 Power Budgeting ................................ 2-3 detectors, hospital ID tags and pet containment TIP #3 Configuring Port Pins ......................... 2-4 systems, to industrial, automotive and medical TIP #4 Use High-Value Pull-Up Resistors ...... 2-4 products. TIP #5 Reduce Operating Voltage ................. 2-4 TIP #6 Use an External Source for PIC MCUs featuring nanoWatt technology CPU Core Voltage .............................. 2-5 implement a variety of important features which TIP #7 Battery Backup for PIC MCUs ........... 2-6 have become standard in PIC microcontrollers. Since the release of nanoWatt technology, DYNAMIC OPERATION TIPS ‘N TRICKS changes in MCU process technology and TIP #8 Enhanced PIC16 Mid-Range Core ..... 2-6 improvements in performance have resulted in TIP #9 Two-Speed Start-Up ........................... 2-7 new requirements for lower power. PIC MCUs TIP #10 Clock Switching .................................. 2-7 with nanoWatt eXtreme Low Power (nanoWatt TIP #11 Use Internal RC Oscillators ................ 2-7 XLP™) improve upon the original nanoWatt TIP #12 Internal Oscillator Calibration ............. 2-8 technology by dramatically reducing static TIP #13 Idle and Doze Modes ......................... 2-8 power consumption and providing new flexibility TIP #14 Use NOP and Idle Mode ...................... 2-9 for dynamic power management. TIP #15 Peripheral Module Disable The following series of Tips n’ Tricks can be (PMD) Bits .......................................... 2-9 applied to many applications to make the most STATIC POWER REDUCTION TIPS ‘N TRICKS of PIC MCU nanoWatt and nanoWatt XLP TIP #16 Deep Sleep Mode ...............................2-10 devices. TIP #17 Extended WDT and Deep Sleep WDT .........................................2-10 GENERAL LOW POWER TIPS ‘N TIP #18 Low Power Timer1 Oscillator TRICKS and RTCC...........................................2-10 TIP #19 Low Power Timer1 Oscillator Layout .. 2-11 The following tips can be used with all PIC TIP #20 Use LVD to Detect Low Battery .......... 2-11 MCUs to reduce the power consumption of TIP #21 Use Peripheral FIFO and DMA ........... 2-11 almost any application. TIP #22 Ultra Low-Power Wake-Up Peripheral ........................... 2-12 © 2009 Microchip Technology Inc. DS01146B-Page 2-1 PIC® Microcontroller Low Power Tips ‘n Tricks TIP #1 Switching Off External Example: Circuits/Duty Cycle The application is a long duration data recorder. All the low power modes in the world won’t help It has a sensor, an EEPROM, a battery and a your application if you are unable to control microprocessor. Every two seconds, it must the power used by circuits external to the take a sensor reading, scale the sensor data, microprocessor. Lighting an LED is equivalent store the scaled data in EEPROM and wait for to running most PIC MCUs at 5V-20 MHz. the next sensor reading. When you are designing your circuitry, decide what physical modes or states are required and partition the electronics to shutdown unneeded circuitry. Figure: 1-1 C2 0.1 µF U1 VDD R2 R4 R5 10k 10k 100k MCLR RA0 RB0/INT U2 R3 RA1 RB1 VCC A0 3.3V F 1k RA2 RB2 WP A1 µ 1 C1 RA3 RB3 SCL A2 0. RA4/TOCKI RB4 SDA GND RB5 Serial EEPROM OSC1/CLKIN RB6 Y1 R1 OSC2/CLKOUT RB7 C3 100k 22 pF VSS 32.768 kHz C5 C4 33 pF PIC16F819 33 pF The system shown above is very simple In Figure 1-2, I/O pins are used to power the and clearly has all the parts identified in the EEPROM and the sensor. Many PIC MCU requirements. Unfortunately, it has a few devices can source up to 20 mA of current problems in that the EEPROM, the sensor, and from each I/O, so there is no need to provide its bias circuit, are energized all the time. To additional components to switch the power. get the minimum current draw for this design, If more current than can be sourced by the PIC it would be advantageous to shutdown these MCU is required, the PIC MCU can instead circuits when they are not required. enable and disable a MOSFET to power Figure: 1-2 the circuit. Refer to the data sheet for drive capabilities for a specific device. C2 0.1 µF U1 VDD R5 R4 R2 100k 10k MCLR 10k RA0 RB0/INT U2 R3 RA1 RB1 VCC A0 1k 3.3V F RA2 RB2 WP A1 µ C1 RA3 RB3 SCL A2 0.1 RA4/TOCKI RB4 SDA GND RB5 Serial EEPROM OSC1/CLKIN RB6 Y1 R1 OSC2/CLKOUT RB7 C3 100k 22 pF VSS 32.768 kHz C5 C4 33 pF PIC16F819 33 pF Page 2-2-DS01146B © 2009 Microchip Technology Inc. PIC® Microcontroller Low Power Tips ‘n Tricks TIP #2 Power Budgeting Computing Battery Life Power budgeting is a technique that is critical to Using the average current from the calculated predicting current consumption and battery life. power budget, it is possible to determine Power budgeting is performed by calculating how long a battery will be able to power the the total charge for each mode of operation application. Table 2 shows lifetimes for typical of an application by multiplying that mode’s battery types using the average power from current consumption by the time in the mode Table 1. for a single application loop. The charge for Capacity Life each mode is added, then averaged over the Battery total loop time to get average current. Table 1 (mAh) Hours Days Months Years calculates a power budget using the application CR1212 18 4180 174 5.8 .48 from Figure 2 in Tip #1 using a typical nanoWatt CR1620 75 17417 726 24.2 1.99 XLP device. CR2032 220 51089 2129 71.0 5.83 Time Current (mA) Charge Alkaline AAA 1250 290276 12095 403.2 33.14 in Current * Mode Alkaline AA 2890 671118 27963 932.1 76.61 Mode By Mode Time Device Total (mS) (mA * Sec) Li-ion* 850 197388 8224 274.1 22.53 Sleep NOTE: Calculations are based on average current draw only and MCU Sleep 0.00005 do not include battery self-discharge. Sensor Off 1989 0 5.00E-05 9.95E-05 EEPROM Off 0 *Varies by size; value used is typical. Initialize MCU Sleep 0.00005 After completing a power budget, it is very easy Sensor On 1 0.0165 1.66E-02 1.66E-05 to determine the battery size required to meet EEPROM Off 0 the application requirements. If too much power Sample Sensor is consumed, it is simple to determine where MCU Run 0.048 additional effort needs to be placed to reduce Sensor On 1 0.0165 6.45E-02 6.45E-05 EEPROM Off 0 the power consumption. Scaling MCU Run 0.048 Sensor Off 1 0 4.80E-02 4.80E-05 EEPROM Off 0 Storing MCU Run 0.048 Sensor Off 8 0 1.05E+00 8.38E-03 EEPROM On 1 Total 2000 — — 8.61E-03 Average Current = 8.61e-3 mA*Sec 2000e-3 Sec = 0.0043 mA Peak Current 1.05 mA © 2009 Microchip Technology Inc. DS01146B-Page 2-3 PIC® Microcontroller Low Power Tips ‘n Tricks TIP #3 Configuring Port Pins TIP #4 Use High-Value Pull-Up All PIC MCUs have bidirectional I/O pins. Some Resistors of these pins have analog input capabilities. It It is more power efficient to use larger pull-up is very important to pay attention to the signals resistors on I/O pins such as MCLR, I2C™ applied to these pins so the least amount of signals, switches and for resistor dividers. For power will be consumed. example, a typical I2C pull-up is 4.7k. However, 2 Unused Port Pins when the I C is transmitting and pulling a line low, this consumes nearly 700 uA of current for If a port pin is unused, it may be left each bus at 3.3V. By increasing the size of the unconnected but configured as an output pin I2C pull-ups to 10k, this current can be halved. driving to either state (high or low), or it may The tradeoff is a lower maximum I2C bus be configured as an input with an external speed, but this can be a worthwhile trade in for resistor (about 10 kΩ) pulling it to VDD or VSS . many low power applications. This technique is If configured as an input, only the pin input especially useful in cases where the pull-up can leakage current will be drawn through the be increased to a very high resistance such as pin (the same current would flow if the pin 100k or 1M. was connected directly to VDD or VSS ). Both options allow the pin to be used later for either TIP #5 Reduce Operating Voltage input or output without significant hardware Reducing the operating voltage of the device, modifications. VDD , is a useful step to reduce the overall power consumption. When running, power Digital Inputs consumption is mainly influenced by the clock A digital input pin consumes the least amount speed. When sleeping, the most significant of power when the input voltage is near VDD factor is leakage in the transistors. At lower or VSS . If the input voltage is near the midpoint voltages, less charge is required to switch the between VDD and VSS , the transistors inside the system clocks and transistors leak less current.