aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/stm32/adc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/stm32/adc.c b/src/stm32/adc.c
index b6aa14b8..3998915f 100644
--- a/src/stm32/adc.c
+++ b/src/stm32/adc.c
@@ -34,6 +34,11 @@ static const uint8_t adc_pins[] = {
#define CR2_FLAGS ADC_CR2_ADON
#endif
+// ADC timing:
+// stm32f103: ADC clock=9Mhz, Tconv=12.5, Tsamp=28.5, total=4.556us
+// stm32f407: ADC clock=21Mhz, Tconv=12, Tsamp=56, total=3.238us
+// stm32f446: ADC clock=22.5Mhz, Tconv=12, Tsamp=56, total=3.022us
+
struct gpio_adc
gpio_adc_setup(uint32_t pin)
{
@@ -72,7 +77,7 @@ gpio_adc_setup(uint32_t pin)
#if CONFIG_MACH_STM32F1
// Perform calibration
- udelay(timer_from_us(1));
+ udelay(10);
adc->CR2 = ADC_CR2_CAL | CR2_FLAGS;
while (adc->CR2 & ADC_CR2_CAL)
;