Datasheet

2010-2016 Microchip Technology Inc. DS40001412G-page 339
PIC18(L)F2X/4XK22
23.3 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
interrupt by setting the HLVDIE and GIE/GIEH
bits (PIE2<2> and INTCON<7>, respectively).
An interrupt will not be generated until the
IRVST bit is set.
23.4 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 Section 27.0 “Electrical
Specifications”. 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.
23.5 HLVD Start-up Time
The internal reference voltage of the HLVD module,
specified in Section 27.0 “Electrical Specifications”,
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.
The HLVD interrupt flag is not enabled until TIRVST 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 Figure 23-2 or
Figure 23-3).
Note: Before changing any module settings
(V
DIRMAG, HLVDL<3:0>), first disable the
module (HLVDEN = 0), make the changes
and re-enable the module. This prevents
the generation of false HLVD events.