And here is my ADC config:
Code: Select all
/*
* ADC conversion group 2.
* Mode: Linear buffer, 1 channel, SW triggered.
* Channels: IN01.
*/
#define ADC_GRP2_NUM_CHANNELS 1
#define ADC_GRP2_BUF_DEPTH 1
adcsample_t samples2[ADC_GRP2_BUF_DEPTH * ADC_GRP2_NUM_CHANNELS];
const ADCConversionGroup adc_grp2_cfg = {
.circular = false,
.num_channels = ADC_GRP2_NUM_CHANNELS,
.end_cb = NULL,
.error_cb = adcerrorcallback,
.cfgr1 = ADC_CFGR1_CONT | ADC_CFGR1_RES_12BIT,
.tr1 = ADC_TR_DISABLED,
.tr2 = ADC_TR_DISABLED,
.tr3 = ADC_TR_DISABLED,
.awd2cr = 0U,
.awd3cr = 0U,
.smpr = ADC_SMPR_SMP_3P5,
.chselr = ADC_CHSELR_CHSEL1
};
I start ADC and then start sampling by executing
Code: Select all
/*
* Starting PORTAB_ADC1 driver and the temperature sensor.
*/
adcStart(&ADCD1, NULL);
adcConvert(&ADCD1, &adc_grp2_cfg, samples2, ADC_GRP2_BUF_DEPTH);
But when I convert read value
Code: Select all
float voltage = samples2 * 18.26f / 4095f; Code: Select all
VREFBUF->CSR = VREFBUF_CSR_ENVR | VREFBUF_CSR_VRS | VREFBUF_CSR_HIZ;Do you have any idea what can be wrong here?