In this use case, the SDADC will be configured with the following settings:
- GCLK generator 0 (GCLK main) clock source
- Internal bandgap reference 1V
- Div 2 clock prescaler
- Over Sampling Ratio is 64
- Skip 2 samples
- MUX input on SDADC AIN1
- All events (input and generation) disabled
- Free running disabled
- Run in standby disabled
- On command disabled
- Disable all positive input in sequence
- Window monitor disabled
- No gain/offset/shift correction
Setup
Prerequisites
There are no special setup requirements for this use-case.
Code
Add to the main application source file, outside of any functions:
Copy-paste the following setup code to your user application:
void configure_sdadc(void)
{
sdadc_init(&sdadc_instance, SDADC, &config_sdadc);
}
Add to user application initialization (typically the start of main()
):
Workflow
- Create a module software instance structure for the SDADC module to store the SDADC driver state while it is in use.
- Note
- This should never go out of scope as long as the module is in use. In most cases, this should be global.
- Configure the SDADC module.
- Create a SDADC module configuration struct, which can be filled out to adjust the configuration of a physical SDADC peripheral.
- Initialize the SDADC configuration struct with the module's default values.
- Note
- This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
- Set SDADC configurations.
sdadc_init(&sdadc_instance, SDADC, &config_sdadc);
- Enable the SDADC module so that conversions can be made.
Use Case
Code
Copy-paste the following code to your user application:
int32_t result;
do {
while (1) {
}
Workflow
- Start conversion.
- Wait until conversion is done and read result.
- Enter an infinite loop once the conversion is complete.