AN879
ack>Yahoo! is not affiliated with the authors of this page or responsible for its content.
AN879
©
2005 Microchip Technology Inc.
DS00879C-page 1
AN879
INTRODUCTION
This application note describes ways to reduce system
current consumption with the use of the Ultra
Low-Power Wake-up (ULPWU) module. Currently, the
PIC16F684 has this module, but other low pin count
parts will have it as well.
The primary use of this module is as an Ultra
Low-Power Wake-up (ULPWU) timer, but its
functionality can be expanded to function as a
temperature sensor and/or a low-voltage detector. The
main and expanded functions of this module are
explained in this document.
Many low-power applications require that the
microprocessor wake-up from a Sleep state on a
periodic basis to check the status of some signal. It can
then react based on a measurement of that signal and
go back to Sleep until the next timed wake-up. This is
a widely used method for reducing overall system
current consumption.
These types of applications require a low-power
periodic wake-up and can be accomplished by
activating a low-power timer prior to placing the device
in a Sleep mode. Upon rollover, the timer interrupt can
then wake-up the part after some predefined period. A
32 kHz crystal timer used on one of the secondary
clock sources is very popular if accuracy is required.
Some parts also have dedicated internal low-power,
low-frequency oscillators that can be used.
One solution for a lower current periodic wake-up timer
is a simple RC timer that can be charged prior to Sleep
and left to slowly discharge. A change in state event
can be used to wake the part when the RC voltage
reaches the digital input threshold voltage. This sounds
ideal, but the problem is that a normal digital-input
structure consumes high-crowbar currents when a
slowly changing voltage is applied to it. The
digital-input structure will consume a few hundred
micro amps when driven by an analog voltage that is
not close to the rail voltages (V
SS
and V
DD
). To combat
these high-crowbar currents, Microchip has introduced
an ULPWU module, which provides an analog input
that can be used to implement a RC timer. The basic
module block diagram is shown in Figure 1.
FIGURE 1:
ULTRA LOW-POWER WAKE-UP PIN DIAGRAM
(1)
Author:
Ruan Lourens
Jose Benavides
Microchip Technology Inc.
INTERNAL
C
V
IL
WRITE
ULPWUE
ANALOG
TRIS
EXTERNAL
I
SINK
Ultra Low-Power Wake-up Module
EVENT
Note 1:
RA0 cannot be read as a digital pin when ULPWU is enabled.
Using the Microchip Ultra Low-Power Wake-up Module
AN879
DS00879C-page 2
©
2005 Microchip Technology Inc.
The module operates as a low-power analog
comparator that compares the voltage on the external
capacitor C to a reference V
IL
. The module generates
an event output when the analog comparator changes
state. The change in state event can generate an
interrupt-on-change. The module provides a very weak
current source to discharge the external capacitor in a
controlled manner. The code in Example 1 initializes
the module; charges the capacitor, enables the
module, and then goes to Sleep, waiting for an
interrupt-on-change.
EXAMPLE 1:
The trip voltage V
IL
and the sink current I
SINK
are
basically independent of V
DD
, but are sensitive to
temperature and process variations. Data for the
module is given in Table 1.
From the data in Table 1, it becomes clear that the
variation in module parameters would limit the overall
accuracy of the timer, when used as in Figure 1. The
wake-up period can vary by as much as 30% between
modules. For a large number of applications, it is
acceptable to have a large variation in the wake-up
period and thus, the modules accuracy is acceptable.
TABLE 1:
MODULE DATA
The module, when enabled, will add between 75 nA
and 160 nA to the microprocessors Sleep current,
depending on process variations, temperature and
voltage. The total expected Sleep current with the
ULPWU module enabled should be only a few hundred
nA for the PIC16F684, since the Sleep current is
typically 1 nA with all peripherals disabled.
The average system current consumption will be higher
due to the energy required to charge the capacitor and
the energy consumed to execute code between Sleep
periods. The time between Sleep periods and active
duty cycle of use will largely dictate the overall current
consumption. A typical smoke detector or Tire
Pressure Monitoring (TPM) system with sub 1
A
current consumption can be achieved.
BCF
STATUS, RP0
;Bank 0
BSF
PORTA, 0
;Set RA0 data latch
MOVLW
H7
;Turn off
MOVWF
CMCON0
;comparators
BSF
STATUS, RP0
;Bank 1
BCF
ANSEL, 0
;RA0 to digital I/O
BCF
TRISA, 0
;Output high to
CALL
CapDelay
;charge capacitor
BSF
PCON, ULPWUE
;Enable ULP Wake-Up
BSF
IOCA, 0
;Select RA0 IOC
BSF
TRISA, 0
;RA0 to input
MOVLW
E10001000
;Enable interrupt
MOVWF
INTCON
;and clear flag
SLEEP
;Wait for IOC
V
IL
(V
DC
)
I
SINK
(nA)
-40°C
Min
0.58
104
Typ
0.69
113
Max
0.81
131
25°C
Min
0.48
121
Typ
0.58
135
Max
0.69
158
85°C
Min
0.38
130
Typ
0.48
145
Max
0.58
169
125°C
Min
0.30
142
Typ
0.40
157
Max
0.49
183
©
2005 Microchip Technology Inc.
DS00879C-page 3
AN879
MODULE APPLICATIONS
The ULPWU modules accuracy and functionality can
be improved by using it as a programmable timer or
using some additional external components. This
includes a programmable low-voltage detect and/or a
temperature sensor. The following sections will briefly
explain these functions.
Basic Timer
Although the operation of the basic wake-up timer has
been discussed, there are more aspects to consider.
Figure 2 shows the addition of a serial resistor when
compared to Figure 1. The resistor R
1
is added if C
1
is
larger than 50 pF. This is done to reduce the peak
current drawn from RA0 while charging C
1
. For larger
capacitors, Equation 1 gives the peak charge current
drawn from RA0. The maximum allowable current
drawn from pin 1 is 25 mA. A resistor of 200 ohm is
sufficient for 5-volt supply voltages and large
capacitors.
FIGURE 2:
SERIAL RESISTOR
EQUATION 1:
Equation 2 gives the discharge period. V
O
is the initial
capacitor voltage and will be the same as V
DD
, if the
capacitor is allowed to fully charge prior to starting the
discharge process.
EQUATION 2:
The discharge period is about 30 ms for a 1 nF
capacitor, a V
O
of 5 V
DC
with a current sink of 140 nA,
and V
IL
of 0.6 V
DC
. The internal current sink is fairly
constant with voltage, assuming the voltage on the
capacitor is V
IL
or more. This results in a near linear
voltage discharge of the capacitor over time. Keep in
mind that the weak current sink is equivalent to very
high-impedance of several tens of mega ohms. Such a
high-impedance discharge system is very sensitive.
Care must be given to layout, the influence of moisture,
and the capacitors self-discharge impedance.
To minimize noise and moisture effects, it is advisable
to keep trace lengths short by placing the discharge
capacitor close to the AN0 pin. Also, note that
capacitors have some internal leakage that will shorten
the discharge period. Different capacitors have
different self-discharge characteristics that will become
important, especially if long discharge periods are
required. Some electrolytic capacitors have fairly high
self-discharge rates that are temperature sensitive.
Use of External Components
For harsh noise and moisture conditions, the stability of
the ULPWU module can be improved by adding an
additional discharge resistor, R
2
, as in Figure 3. The
voltage discharge on C
1
, due to R
2
, will follow
Equation 3, if the current through R
2
is large compared
to the discharge current I
SINK
. Thus, the discharge
period can be derived as in Equation 4.
FIGURE 3:
DISCHARGE RESISTOR
EQUATION 3:
R
1
C
1
RA0
I
PEAK
=
I
PEAK
=
V
DD
for C
1
>> 50 pF
R
1
peak charge current
T
DISCHARGE
=
T
DISCHARGE
=
discharge period
V
O
=
initial capacitor voltage
V
IL
=
trip voltage
I
SINK
=
sink current
I
LEAKAGE
=
capacitors internal leakage current
(V
O
V
IL
) C
.
I
SINK
+ I
LEAKAGE
R
1
C
1
RA0
R
2
(
)
T
C
1
R
2
V(T) = V
O
e
.
V(T) =
voltage across capacitor
V
O
=
initial capacitor voltage
T =
time
AN879
DS00879C-page 4
©
2005 Microchip Technology Inc.
EQUATION 4:
Calibrated Timer
The following section explains how the accuracy of the
basic timer can be improved by controlling the charge
period. The discharge period for both implementations
shown in Figures 2 and 3 are dependent on V
O
, C
1
, V
IL
and I
SINK
or R
2
. These parameters depend on process
variations, temperature effects, usage and more. A
software calibrated Sleep timer will compensate for
some of these variations by controlling V
O
. Timing the
charge period of C
1
through R
1
allows control over the
voltage on C
1
at the start of the Sleep period V
O
. The
discharge period T
DISCHARGE
is timed against the main
clock source while the part is awake, then the charge
period can be adjusted based on the T
DISCHARGE
error.
This process is repeated until the desired accuracy is
obtained. Repeat the calibration process after a fixed
amount of normal Sleep periods, to maintain accuracy
over time.
Pay close attention to the residual charge across C
1
at
the start of the charge period. There may be charge left
in C
1
, depending on V
IL
and whether or not the ULPWU
module was disabled, and whether RA0 turned into an
analog input, digital input or digital output. One
approach is to ful