18.2.5 Operation with ADC

The Analog Peripheral Manager can be used to periodically activate the ADC module to control the timing in which conversions are performed. The ADC is unique in comparison to the other analog modules that can be controlled by the APM, as it has separate Peripheral Start and Stop Enable bits to enable the ADC and trigger a conversion.

Setting the ADCA bit in the APM Peripheral Start Registers will allow the APM to enable the ADC module and the analog references needed when the respective Start Event occurs and prepare it to perform conversions. Setting the ADCD bit in the APM Peripheral Start Registers will allow the APM module to trigger an ADC conversion when the respective Start Event occurs. The Analog Peripheral Manager must be selected as the ADC Auto-Conversion Trigger source in order for the APM to be capable of automatically triggering ADC conversions. Refer to the "Auto-Conversion Trigger" section in the “Analog-to-Digital Converter with Computation and Context" chapter for more information.

Additionally, it is important to ensure enough time has lapsed after an ADCA Start Event to allow the ADC to stabilize so that it is ready to perform a conversion before an ADCD Start Event occurs. Setting the ADCD bit will not only allow the APM to trigger an ADC conversion, but also enables threshold comparison and other computation features of the ADC.

When using the APM module, the ADC module must be enabled before a triggering a conversion; generally the ADCA Start Event must occur before the ADCD Start Event to ensure that the controller has been enabled and initialized before a conversion is triggered. The ADCA and ADCD End Events can both occur at the same time once the ADC conversion has been completed. It is important to ensure enough time has lapsed after a conversion has been triggered (ADCD Start Event) to account for the complete ADC conversion time before the ADC is disabled again by the APM. If the ADCA or ADCD bits of either the APMPERE1 or APMPERE2 registers are cleared before the ADC conversion has been completed, the results may be incorrect.