43.5.9 Capacitive Voltage Divider (CVD) Features

The ADC module contains several features that allow the user to perform a relative capacitance measurement on any ADC channel using the internal ADC Sample-and-Hold capacitance as a reference. This relative capacitance measurement can be used to implement capacitive touch or proximity sensing applications. The following figure shows the basic block diagram of the CVD portion of the ADC module.

Figure 43-7. Hardware Capacitive Voltage Divider Block Diagram
This is an example to configure ADC for CVD operation:
  1. Configure Port:
    1. Disable pin output driver (refer to the TRISx register)
    2. Configure pin as analog (refer to the ANSELx register)
  2. Configure the ADC module:
    1. Select ADC conversion clock
    2. Configure voltage reference
    3. Select ADC input channel
    4. Configure precharge (ADPRE) and acquisition (ADACQ) time period
    5. Select precharge polarity (PPOL)
    6. Enable Double Sampling (DSEN)
    7. Turn on ADC module
  3. Configure ADC interrupt (optional):
    1. Clear the ADC interrupt flag
    2. Enable the ADC interrupt
    3. Enable global interrupt (GIE bit)(1)
  4. Start double sample conversion by setting the GO bit.
  5. Wait for ADC conversion to complete by one of the following:
    • Polling the GO bit
    • Waiting for the ADC interrupt (if interrupt is enabled)
  6. Second ADC conversion depends on the state of CONT:
    1. If CONT = 1, both conversion will repeat automatically form a single trigger.
    2. If CONT = 0, each conversion must be triggered separately.
  7. ADERR register contains the CVD result
  8. Clear the ADC interrupt flag (if interrupt is enabled).
Note:
  1. With global interrupts disabled (GIE = 0), the device will wake from Sleep, but will not enter an Interrupt Service Routine.