Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

PIC24F Family Reference Manual
DS39724B-page 11-12 © 2010 Microchip Technology Inc.
11.4 CTMU MODULE INITIALIZATION
The following sequence is a general guideline used to initialize the CTMU module:
1. Select the current source range using the IRNG bits (CTMUICON<9:8>).
2. Adjust the current source trim using the ITRIM bits (CTMUICON<15:10>).
3. Configure the edge input sources for Edge 1 and Edge 2 by setting the EDG1SEL and
EDG2SEL bits (CTMUCON<3:2> and <6:5> or CTMUCON2<13:10> and <5:2>).
4. Configure the input polarities for the edge inputs using the EDG1POL and EDG2POL bits
(CTMUCON<7:4> or CTMUCON2<14:6>). The default configuration is for negative edge
polarity (high-to-low transitions).
5. Enable edge sequencing using the EDGSEQEN bit (CTMUCON<10> or
CTMUCON1<10>). By default, edge sequencing is disabled.
6. Select the operating mode (Measurement or Time Delay) with the TGEN bit. The default
mode is Time/Capacitance Measurement.
7. Configure the module to automatically trigger an A/D conversion when the second edge
event has occurred using the CTTRIG bit (CTMUCON<8> or CTMUCON1<8>). The
conversion trigger is disabled by default.
8. Discharge the connected circuit by setting the IDISSEN bit (CTMUCON<9> or
CTMUCON1<9>); after waiting a sufficient time for the circuit to discharge, clear IDISSEN.
9. Disable the module by clearing the CTMUEN bit (CTMUCON<15> or CTMUCON1<15>).
10. Clear the Edge Status bits, EDG2STAT and EDG1STAT (CTMUCON<1:0> or
CTMUCON2<9:8>).
11. Enable both edge inputs by setting the EDGEN bit (CTMUCON<11> or
CTMUCON1<11>).
12. Enable the module by setting the CTMUEN bit.
Depending on the type of measurement or pulse generation being performed, one or more
additional modules may also need to be initialized and configured with the CTMU module:
Edge Source Generation: In addition to the external edge input pins, both Timer1 and the
Output Compare/PWM1 module can be used as edge sources for the CTMU.
Capacitance or Time Measurement: The CTMU module uses the A/D Converter to measure
the voltage across a capacitor that is connected to one of the analog input channels.
Pulse Generation: When generating system clock independent output pulses, the CTMU
module uses Comparator 2 and the associated comparator voltage reference.
For specific information on initializing these modules, refer to the applicable PIC24F Family
Reference Manual section for the appropriate module.
11.5 CALIBRATING THE CTMU MODULE
The CTMU requires calibration for precise measurements of capacitance and time, as well as for
accurate time delay. If the application only requires measurement of a relative change in capac-
itance or time, calibration is usually not necessary. An example of this type of application would
include a capacitive touch switch, in which the touch circuit has a baseline capacitance and the
added capacitance of the human body changes the overall capacitance of a circuit.
If actual capacitance or time measurement is required, two hardware calibrations must take
place: the current source needs calibration to set it to a precise current, and the circuit being
measured needs calibration to measure and/or nullify all other capacitance other than that to be
measured.

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh