stm32h7xx-hal
stm32h7xx-hal copied to clipboard
Changing the ADC clock prescaler needs a workaround.
Hi, I've been trying to set the clock prescaler for the internal ADCs and found it to be rather cumbersome.
The adc initialization function does not use or do anything with the ADC_COMMON registers in which the clock configuration takes place. Manually changing anything in these registers only works after the ADC is initialized (since it is reset in init) and before it is enabled (condition form datasheet). But then the ADC has to be re-calibrated again since the clock impacts the offset values. I've tested this here.
All in all it might be nicer to incorporate the clock prescaler and clock mode from ADC_COMMON into the init function. But I'm not sure how to do this in the best way. I think it would be a breaking change in any way, right?
Additionally we now found that the 100 MHz maximum clock input that the HAL checks for is never a valid clock frequency. https://github.com/quartiq/stabilizer/issues/571
"never" as in "in the recent RMs the ADC max clock is 80 MHz".
Thanks for reporting! Indeed the clock prescaler (and potentially also clock mode) should be integrated into the init function. It is a breaking change, but necessary so let's do it.
Closed in #379