1.32.2.8 ADCx_LastConversionResultGet Function

C

uint16_t ADCx_LastConversionResultGet( void ); // x is instance of the peripheral and it is applicable only for devices having multiple instances of the peripheral.

Summary

Returns the result for the previous adc conversion of the channel.

Description

This function returns the result of previous completed conversion of the channel.

Precondition

ADCx_Initialize() function must have been called first for the associated instance and conversion must have been started. Also check whether result is ready to read.

Parameters

None.

Returns

adcResult - result of the previous adc conversion of the channel.

Example

uint16_t adcResultPrev = 0;
uint16_t adcResultCurrent = 0;
ADC0_Initialize();
ADC0_ConversionStart();
while(!ADC0_ConversionStatusGet());
ADC0_ConversionStart();
while(!ADC0_ConversionStatusGet());
adcResultPrev = ADC0_LastConversionResultGet();
adcResultCurrent = ADC0_ConversionResultGet();

Remarks

This function can be called from interrupt or by polling the status when result is available. User should decode the result based on result sign mode (differential mode) and result resolution (8, 10, 12 or 16 bit) configuration.