We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4f676cd commit 596670bCopy full SHA for 596670b
cpu/stm32/periph/adc_f2.c
@@ -96,6 +96,13 @@ int adc_init(adc_t line)
96
assume((periph_apb_clk(APB2) / clk_div) <= ADC_CLK_MAX);
97
ADC->CCR = ((clk_div / 2) - 1) << 16;
98
99
+ if (IS_USED(MODULE_PERIPH_VBAT)) {
100
+ /* Set the sampling rate for the VBat channel to 112 cycles. It reads
101
+ * correct with 84 cycles already, so this adds some margin. */
102
+ ADC1->SMPR1 = (ADC1->SMPR1 & ~ADC_SMPR1_SMP18) | \
103
+ (ADC_SMPR1_SMP18_2 | ADC_SMPR1_SMP18_0);
104
+ }
105
+
106
/* enable the ADC module */
107
dev(line)->CR2 = ADC_CR2_ADON;
108
0 commit comments