## SAR_ADC Function Documentation

### Sys_Calibrate_SARADC

void Sys_Calibrate_SARADC(uint32_t vddsar_mv, uint32_t supply_src, uint32_t * offset, float * gain)

Calibrate the SAR ADC, generating gain and offset values.

The gain and offset values are stored in the SAR ADC but are returned here as well.

Location: sar_adc.h:106

Parameters

Direction | Name | Description
--- | --- | ---
in | vddsar_mv | Set the SAR supply voltage. 2.5 to 3.3 V sets SENSOR_CLK between 8 and 16 MHz. Less than 2.5 V sets SENSOR_CLK to 2 MHz.
in | supply_src | Select the SAR supply source: use SAR_SUPPLY_BY_VBAT, SAR_SUPPLY_BY_GPIO9
out | offset | Gets the offset stored in SAR_ADC
out | gain | Gets the calibrated gain correction

Assumptions

The SAR ADC is configured to use VBAT for the calibration.

Example Code for Sys_Calibrate_SARADC
// Calibrate the SAR ADC with SAR positive input having signal between VSSA // and 3000mV. // Set gain_correction to the calibrated gain correction // Set sar_adc_offset to the offset stored in SAR-ADC (i.e. 8192 levels) float gain_correction = 0; uint32_t sar_adc_offset = 0; Sys_Calibrate_SARADC(SAR_ADC_VBAT_SUPPLY_MV, SAR_SUPPLY_BY_VBAT, &sar_adc_offset, &gain_correction);