Description
Hi,
I've been running into some issues configuring the ADC in a non-standard configuration (I'm using injected channels, I realize that isn't currently supported by the library, but I'm trying to use the library as much as possible and I hope to contribute a PR in the near future).
I find that in certain cases the ADC will hang in the calibration step. I believe I've tracked it down to section 21.4.10 of the reference manual (screenshot below), which states that writes to CFGR
, SMPRx
, TRy
, SQRy
, JDRy
, OFRy
, OFCHRy
and IER
registers are only allowed when the ADC is enabled but not started (and there's no hardware protection against this, and it can result in undefined ADC behavior).
In other words, most of the configuration accessors implemented on impl Adc<stm32::$adc_type, Disabled>
should instead be implemented on impl Adc<stm32::$adc_type, Configured>
(set_resolution
, set_align
, set_external_trigger
, set_continuous
, etc.).
In my case I see different behavior on 0.0.1 compared to head of main, with main being more sensitive to the register access sequencing.
Does this sound plausible? I was surprised by this section of the reference manual, but it seems to fix the issue in my case.
