internal adc: use per clk
@@ -268,6 +268,8 @@ pub fn setup(
device.RCC.d1ccipr.modify(|_, w| w.qspisel().rcc_hclk3());
+ device.RCC.d3ccipr.modify(|_, w| w.adcsel().per());
+
let rcc = device.RCC.constrain();
let ccdr = rcc
.use_hse(8.MHz())
@@ -737,25 +739,22 @@ pub fn setup(
let (mut adc1, mut adc2) = hal::adc::adc12(
device.ADC1,
device.ADC2,
- stm32h7xx_hal::time::Hertz::MHz(12),
+ stm32h7xx_hal::time::Hertz::MHz(25),
&mut delay,
ccdr.peripheral.ADC12,
&ccdr.clocks,
);
let mut adc3 = hal::adc::Adc::adc3(
device.ADC3,
- stm32h7xx_hal::time::Hertz::MHz(12),
+ stm32h7xx_hal::time::Hertz::MHz(25),
&mut delay,
ccdr.peripheral.ADC3,
&ccdr.clocks,
);
- // Set ADC clock prescaler after adc init but before enable
- device.ADC12_COMMON.ccr.modify(|_, w| w.presc().div2());
- device.ADC3_COMMON.ccr.modify(|_, w| w.presc().div2());
adc1.set_sample_time(hal::adc::AdcSampleTime::T_810);
adc1.set_resolution(hal::adc::Resolution::SixteenBit);
- adc1.calibrate(); // re-calibrate after clock has changed
+ adc1.calibrate();
adc2.set_sample_time(hal::adc::AdcSampleTime::T_810);
adc2.set_resolution(hal::adc::Resolution::SixteenBit);
adc2.calibrate();
