8-Bit PIC Analog-to-Digital Converter with Computation

Last modified by Microchip on 2023/11/09 09:02

The Analog-to-Digital Converter (ADC), with computation module (ADCC), in Microchip’s latest family of 8-bit MCUs, has a built-in computational feature that provides post-processing functions such as oversampling, averaging, and low-pass filtering.


The analog input channel sources are multiplexed into a single sample and hold circuit. The output of the sample and hold circuit is connected to the converter, which generates a binary representation of the analog input. When the ADC is operating with computational features, the conversion result will be passed onto the computational feature block for post-processing. The post-processing result is then evaluated using error calculation and threshold comparison.

Channel Selection Source

The ADCC Channel Selection (ADPCH) register determines which channel is connected to the sample and hold circuit. Channel selection sources are not limited to external analog input sources but can also be an output of a peripheral or an internal reference voltage.

Back to Top

Voltage Reference Source

The voltage reference sets the input voltage range of the ADC. It can be an external source from the VREF+/- pins, VDD , FVR, and VSS.

Conversion Clock Source

The conversion clock has multiple sources, either from the main oscillator, which is divided into multiples of two (i.e., 2, 4, or 128), or from the dedicated internal resistance-capacitance (RC) clock.

Back to Top

Auto-Conversion Trigger Source

The auto-conversion trigger allows the module to schedule acquisition and conversion sequences without software intervention. When a rising edge of the selected source occurs, the ADC Conversion Status (ADGO) bit is set. The sources for the auto-conversion trigger can be found on the device datasheet for the device you are using. In an application, these auto-conversion trigger sources can be used to set the sampling period of the ADC.

Back to Top

Operational Modes

Below are the various modes available. Many of the descriptions include an image that visually describes the mode's operation along with an MPLAB® Code Configurator screenshot indicating how the mode is easily set up. After each mode is completed a Threshold Comparison is performed.

Basic Mode

The Basic mode of the ADCC mimics the legacy ADC operation. With the auto-trigger feature of the module, input sampling can be easily triggered in the software or by other peripherals and external sources. The result of the conversion can be compared to a threshold set point which may trigger the Analog-to-Digital Converter Interrupt Flag.

Back to Top

Accumulate Mode

In the Accumulate mode, the digital representation of the analog input signal in the 10-bit/12-bit register ADC Result High/Low(ADRESH) / (ADRESL) register is accumulated to the 16-bit ADC Accumulator Register (ADACC) register. With each sample, the ADC Conversion Counter (ADCNT) register is incremented, indicating the number of samples accumulated. The accumulated value can be right shifted up to six times by changing the value of the ADC Accumulate Calculation Right Shift Select (ADCRS) bits of the ADC Control Register 2 (ADCON2) register. This means that the accumulated value is effectively divided by a factor of two (2ADCRS). The result of the shifted accumulated value is stored in the ADC Filter (ADFLTR) register.

accumulate mode

Back to Top

Averaging Mode

The Average mode is like an accumulate mode wherein the ADACC accumulates the data sample and the ADCNT increments with each sample, except that the number of samples being accumulated in this mode is up to the value set in the A/D Repeat Setting (ADRPT) register. When the ADCNT is equal to ADRPT, the value stored in the ADFLTR becomes the average value of the input signal. This mode can be used when a defined time interval is needed for each sample.

averaging mode

Back to Top

Burst Average Mode

Like Averaging mode, the Burst Average mode averages the input signal except that the sampling is repeated quickly after a single trigger. This means that in a single conversion, all the data samples are accumulated up to the set ADRPT and when the ADCNT matches the set ADPRT value, the average value of the input signal is attained.

burst average mode

Back to Top

Low-Pass Filter Mode

The Low-pass Filter mode acts similarly to the Average mode in how it handles samples (accumulates samples until ADCNT value is greater than or equal to ADRPT, then triggers threshold comparison), but instead of a simple average, it performs a lowpass filter operation on all of the samples, reducing the effect of high-frequency noise on the average, then performs a threshold comparison on the results. In this mode, the ADCRS bits determine the cut-off frequency of the low-pass filter.

With each trigger, the ADC conversion result is sent through a filter. When ADRPT samples have occurred, a threshold test is performed. Every trigger after that the ADC conversion result is sent through the filter and another threshold test is performed.

low-pass filter mode

Back to Top

ADCC Output Actions

Threshold Comparison

The post-processing result of the ADCC module can be compared to the threshold value set in the ADC Error Calculation Mode Select bits (ADCALC) of the ADC Threshold (ADCON3) register. The calculated result is stored in the ADC Calculation Error (ADERR) register, which can be compared to the selected upper or lower threshold. These two threshold values can be set by changing the ADC Upper Threshold (ADUTH) registers and the ADC Lower Threshold (ADLTH) registers. A result of true, based on the comparison, will trigger an interrupt.

Back to Top

Continuous Mode Retrigger

Enabling the Continuous mode allows an automatic sampling retrigger after the threshold has been tested. In this mode, the ADGO of the ADC Control 0 (ADCON0) register remains set until the threshold conditions are met according to the selected Threshold Interrupt Mode Select bits (ADTMD) and the A/D Stop On Interrupt bit (ADSOI) of the ADCON3.

Back to Top