Microchip Technology MCU PIC PIC18F87K22-I/PTRSL TQFP-80 MCP PIC18F87K22-I/PTRSL Data Sheet

Product codes
PIC18F87K22-I/PTRSL
Page of 550
 2009-2011 Microchip Technology Inc.
DS39960D-page 381
PIC18F87K22 FAMILY
26.2
HLVD Setup
To set up the HLVD module:
1.
Select the desired HLVD trip point by writing the
value to the HLVDL<3:0> bits.
2.
Set the VDIRMAG bit to detect high voltage
(VDIRMAG = 1) or low voltage (VDIRMAG = 0).
3.
Enable the HLVD module by setting the
HLVDEN bit.
4.
Clear the HLVD interrupt flag (PIR2<2>), which
may have been set from a previous interrupt.
5.
If interrupts are desired, enable the HLVD inter-
rupt by setting the HLVDIE and GIE bits
(PIE2<2> and INTCON<7>, respectively). 
An interrupt will not be generated until the
IRVST bit is set.
26.3
Current Consumption
When the module is enabled, the HLVD comparator
and voltage divider are enabled and consume static
current. The total current consumption, when enabled,
is specified in electrical specification Parameter D022B
(
).
Depending on the application, the HLVD module does
not need to operate constantly. To reduce current
requirements, the HLVD circuitry may only need to be
enabled for short periods where the voltage is checked.
After such a check, the module could be disabled.
26.4
HLVD Start-up Time
The internal reference voltage of the HLVD module,
specified in electrical specification Parameter 
(
), may be
used by other internal circuitry, such as the
programmable Brown-out Reset. If the HLVD or other
circuits using the voltage reference are disabled to
lower the device’s current consumption, the reference
voltage circuit will require time to become stable before
a low or high-voltage condition can be reliably
detected. This start-up time, T
IRVST
, is an interval that
is independent of device clock speed. It is specified in
electrical specification Parameter 
).
The HLVD interrupt flag is not enabled until T
IRVST
 has
expired and a stable reference voltage is reached. For
this reason, brief excursions beyond the set point may
not be detected during this interval (see 
Note:
Before changing any module settings
(V
DIRMAG
, LVDL<3:0>), first disable the
module (LVDEN = 0), make the changes
and re-enable the module. This prevents
the generation of false HLVD events.