1.34.1.8 AFECx_ChannelResultGet Function

C

uint16_t AFECx_ChannelResultGet (AFEC_CHANNEL channel) // x - Instance of the AFEC peripheral

Summary

Reads the conversion result of the channel

Description

This function reads the conversion result of the channel

Precondition

AFECx_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;
AFEC0_Initialize();
AFEC0_ChannelsEnable(AFEC_CH0);
AFEC0_ConversionStart();
status = AFEC0_ChannelResultIsReady(AFEC_CH0);
if (status)
{
    result = AFEC0_ChannelResultGet(AFEC_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, 14, 15 or 16 bit result) configuration.