English
Language : 

PIC18F87K22 Datasheet, PDF (397/548 Pages) Microchip Technology – 64/80-Pin, High-Performance, 1-Mbit Enhanced Flash Microcontrollers with 12-Bit A/D and nanoWatt XLP Technology
PIC18F87K22 FAMILY
27.7 Creating a Delay with the CTMU
Module
A unique feature on board the CTMU module is its ability
to generate system clock independent output pulses
based on either an external voltage or an external
capacitor value. When using an external voltage, this is
accomplished using the CTDIN input pin as a trigger for
the pulse delay. When using an external capacitor
value, this is accomplished using the internal compara-
tor voltage reference module and Comparator 2 input
pin.The pulse is output onto the CTPLS pin. To enable
this mode, set the TGEN bit.
See Figure 27-4 for an example circuit. When
CTMUDS (ODCON3<0>) is cleared, the pulse delay is
determined by the output of Comparator 2, and when it
is set, the pulse delay is determined by the input of
CTDIN. CDELAY is chosen by the user to determine the
output pulse width on CTPLS. The pulse width is calcu-
lated by T = (CDELAY/I)*V, where I is known from the
current source measurement step (Section 27.4.1
“Current Source Calibration”) and V is the internal
reference voltage (CVREF).
An example use of the external capacitor feature is
interfacing with variable capacitive-based sensors,
such as a humidity sensor. As the humidity varies, the
pulse-width output on CTPLS will vary. An example use
of the CTDIN feature is interfacing with a digital sensor.
The CTPLS output pin can be connected to an input
capture pin and the varying pulse width measured to
determine the sensor’s output in the application.
To use this feature:
1. If CTMUDS is cleared, initialize Comparator 2.
2. If CTMUDS is cleared, initialize the comparator
voltage reference.
3. Initialize the CTMU and enable time delay
generation by setting the TGEN bit.
4. Set EDG1STAT.
When CTMUDS is cleared, as soon as CDELAY charges
to the value of the voltage reference trip point, an out-
put pulse is generated on CTPLS. When CTMUDS is
set, as soon as CTDIN is set, an output pulse is
generated on CTPLS.
FIGURE 27-4:
TYPICAL CONNECTIONS AND INTERNAL CONFIGURATION FOR PULSE DELAY
GENERATION
CTEDG1
CTMUI
PIC18F87K22
CTMU
EDG1
Current Source
Comparator
C2
CTPLS
CTMUDS
CTDIN
CDELAY
CVREF
C1
External Reference
External Comparator
 2010 Microchip Technology Inc.
Preliminary
DS39960B-page 397