This is the quickstart guide for the SAM ADCIFE driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases.
The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.
Basic use case
In this basic use case, the ADCIFE module and single channel are configured for:
- 12-bit, unsigned conversions
- Internal bandgap as 1.0 V reference
- ADC clock rate of at most 1.8 MHz and maximum sample rate is 300 KHz
- Software triggering of conversions
- Interrupt-based conversion handling
- Single channel measurement
- ADC_CHANNEL_13 as positive input
Prerequisites
- System Clock Management (Sysclock)
Setup steps
Example code
Add to application C-file:
void adcife_read_conv_result(void)
{
}
}
};
};
void adc_setup(void)
{
ADCIFE_IRQn, 1);
}
Workflow
- Define the interrupt service handler in the application:
void adcife_read_conv_result(void)
{
}
}
- Note
- Get ADCIFE status and check if the conversion is finished. If done, read the last ADCIFE result data.
- Initialize ADC Module:
- Enable ADC Module:
- Configure ADC single sequencer with specified value.:
- Set callback for ADC:
Usage steps
Example code
Add to, e.g., main loop in application C-file:
Workflow
- Start ADC conversion on channel: