English
Language : 

PIC18F44J50-I Datasheet, PDF (411/562 Pages) Microchip Technology – 28/44-Pin, Low-Power, High-Performance USB Microcontrollers
PIC18F46J50 FAMILY
26.5 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 by following these steps:
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 26.3.1 “Current Source Calibration”),
C is calculated in the capacitance calibration step
(Section 26.3.2 “Capacitance Calibration”) and
V is measured by performing the A/D conversion.
It is assumed that the time measured is small enough
that the capacitance, CAD + CEXT, provides a valid volt-
age to the A/D Converter. For the smallest time
measurement, always set the A/D Channel Select reg-
ister (AD1CHS) to an unused A/D channel; the
corresponding pin 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. To measure longer time intervals,
an external capacitor may be connected to an A/D
channel and this channel selected when making a time
measurement.
FIGURE 26-3:
TYPICAL CONNECTIONS AND INTERNAL CONFIGURATION FOR TIME
MEASUREMENT
CTED1
CTED2
PIC18F46J50 Device
CTMU
EDG1 Current Source
EDG2
A/D Voltage
ANX
CEXT
A/D Converter
CAD
 2011 Microchip Technology Inc.
DS39931D-page 411