The steps to configure the AFEC are listed below. They are given in more
detail in the following section.
- 1.Configure the GPIO for AFEC. (If not already done by default).
- 2.Initialize the AFEC with AFEC_Initialize(). (PMC configuration).
- 3.Configure the AFEC Mode Register.
- 4.Set AFEC clock with AFEC_SetClock().
- 5.Select the active channel using AFEC_EnableChannel().
- 6.Adjust the Channel Offset Correction to get a good single-ended result form.
- 7.Enable the PGA0 and PGA1 of the AFEC0 and adjust the performances by tuning the AFE
Bias Current Control.
- 8.Configure the Extended Mode Register (AFEC_EMR) by enabling/disabling averaging,
enabling the channel tag and using the Single Trigger mode.
- 9.Start the conversion with AFEC_StartConversion().
- 10.Wait for the end of the conversion by polling the status with AFEC_GetStatus().
- 11.Get the converted data using AFEC_GetConvertedData() or
AFEC_GetLastConvertedData().
The implementation can directly start from the main.c file just before the main
function.
The first function to implement is the AFEC initialization function:
/**
* \brief Initialize AFE.
*
*/
static void _afe_initialization(void)
{
}
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/**
* \brief getting-started Application entry point.
*
* \return Unused (ANSI-C compatibility).
*/
extern int main( void )
{
/* Disable watchdog */
WDT_Disable( WDT ) ;
….