|
@@ -442,9 +442,11 @@ void HAL_adc_init() {
|
442
|
442
|
// Preloaded data (fixed for all ADC instances hence not loaded by DMA)
|
443
|
443
|
adc->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA_Val; // VRefA pin
|
444
|
444
|
SYNC(adc->SYNCBUSY.bit.REFCTRL);
|
445
|
|
- adc->CTRLB.bit.RESSEL = ADC_CTRLB_RESSEL_10BIT_Val;
|
|
445
|
+ adc->CTRLB.bit.RESSEL = ADC_CTRLB_RESSEL_12BIT_Val;
|
446
|
446
|
SYNC(adc->SYNCBUSY.bit.CTRLB);
|
447
|
447
|
adc->SAMPCTRL.bit.SAMPLEN = (6 - 1); // Sampling clocks
|
|
448
|
+ adc->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_16 | ADC_AVGCTRL_ADJRES(4); // 16 Accumulated conversions and shift 4 to get oversampled 12 bits result
|
|
449
|
+ SYNC(adc->SYNCBUSY.bit.AVGCTRL);
|
448
|
450
|
// Registers loaded by DMA
|
449
|
451
|
adc->DSEQCTRL.bit.INPUTCTRL = true;
|
450
|
452
|
|