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 399
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 
 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. C
DELAY
 is chosen by the user to determine the
output pulse width on CTPLS. The pulse width is calcu-
lated by T = (C
DELAY
/I) * V, where I is known from the
current source measurement step (
) and V is the Internal
Reference Voltage (CV
REF
).
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 C
DELAY
 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
C2
CV
REF
CTPLS
Current Source
Comparator
CTMU
CTED1
CTMUI
C
DELAY
EDG1
PIC18F87K22
CTMUDS
C1
External Reference
External Comparator
CTDIN