stm32h7xx-hal icon indicating copy to clipboard operation
stm32h7xx-hal copied to clipboard

Changing the ADC clock prescaler needs a workaround.

Open nkrackow opened this issue 1 year ago • 3 comments

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?

nkrackow avatar Jul 28 '22 09:07 nkrackow

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

nkrackow avatar Jul 28 '22 13:07 nkrackow

"never" as in "in the recent RMs the ADC max clock is 80 MHz".

jordens avatar Aug 09 '22 10:08 jordens

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.

richardeoin avatar Aug 14 '22 21:08 richardeoin

Closed in #379

richardeoin avatar Sep 26 '22 19:09 richardeoin