English
Language : 

PIC18F87K90 Datasheet, PDF (418/566 Pages) Microchip Technology – 64/80-Pin, High-Performance Microcontrollers with LCD Driver and nanoWatt XLP Technology
PIC18F87K90 FAMILY
27.6 Measuring Time with the CTMU
Module
Time can be precisely measured after the ratio (C/I) is
measured from the current and capacitance calibration
step. To do that:
1. Initialize the A/D Converter and the CTMU.
2. Set EDG1STAT.
3. Set EDG2STAT.
4. Perform an A/D conversion.
5. Calculate the time between edges as T = (C/I) • V,
where:
• I is calculated in the current calibration step
(Section 27.4.1 “Current Source Calibration”)
• C is calculated in the capacitance calibration step
(Section 27.4.2 “Capacitance Calibration”)
• V is measured by performing the A/D conversion
It is assumed that the time measured is small enough
that the capacitance, COFFSET, provides a valid voltage
to the A/D Converter. For the smallest time measure-
ment, always set the A/D Channel Select register
(AD1CHS) to an unused A/D channel, the correspond-
ing pin for which is not connected to any circuit board
trace. This minimizes added stray capacitance,
keeping the total circuit capacitance close to that of the
A/D Converter itself (25 pF).
To measure longer time intervals, an external capacitor
may be connected to an A/D channel and that channel
selected whenever making a time measurement.
FIGURE 27-3:
TYPICAL CONNECTIONS AND INTERNAL CONFIGURATION FOR TIME
MEASUREMENT
CTEDG1
CTEDG2
PIC18F87K90
CTMU
EDG1 Current Source
EDG2
Output Pulse
ANX
RPR
A/D Converter
CAD
DS39957B-page 418
Preliminary
 2010 Microchip Technology Inc.