1.36.1.8 ADC_ChannelResultGet Function

C

uint16_t ADC_ChannelResultGet (ADC_CHANNEL channel)
uint16_t ADC_ChannelResultGet (ADC_CHANNEL_NUM channel)

Summary

Reads the conversion result of the channel

Description

This function reads the conversion result of the channel

Precondition

ADC_Initialize() must have been called first for the associated instance. And conversion must have been started.

Parameters

Param Description
channel channel number

Returns

uint16_t - conversion result

Example

uint16_t result;
bool status;
ADC_Initialize();
ADC_ChannelsEnable(ADC_CH0);
ADC_ConversionStart();
status = ADC_ChannelResultIsReady(ADC_CH0);
if (status)
{
    result = ADC_ChannelResultGet(ADC_CH0);
}

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 (signed or unsigned result) and result resolution (12, 13 or 14 bit result) configuration.