Electronic – STM32F4 ADC: Dual interleaved + Independent

adcmicrocontrollerstm32f4stm32f4-discovery

Some STM32F4 microcontrollers have 3 ADCs on board, they can be configured in various modes.
I wonder is it possible to configure ADC1 and ADC2 in "Dual interleaved" mode, but have ADC3 configured as independent channel?

When generating project in CubeMX, if I turn on all 3 ADCs, and select for example "Dual interleaved mode only" in ADC1 – all other ADC default to this mode without possibility to change it. This is quite weird, since CubeMX basically says that all 3 ADCs are configured in dual interleaved mode, which is illogical (3 ADCs working in Dual…). There is no way to change ADC3 to any other mode, even though having it as "Independent" seems to be the only logical solution.

On page 402 here under bullet 2 it says "In the Dual ADC mode, the ADC3 slave part is not present.", I am not sure what is meant by that: is ADC3 as a whole is not working in dual mode or simply ADC3 is not SLAVE anymore?
I'm afraid it is the only reference to ADC3 in dual mode in official reference manual.

On page 78 here it says "ADC1 master and ADC2 slave, ADC3 is independently.", which kinda suggests that ADC3 can be configured as independent, but this pdf doesn't describe it any further.

I also found this application note, but it is only for microcontrollers with 2 ADCs inside. If there is the same note but taking into account ADC3 – please share, I haven't found it.

So the following questions arise:

  1. Is CubeMX bugged? I mean, clearly there is no sense to configure 3 ADCs in dual configuration. It either has to set ADC3 to independent mode or show error message "You can't use ADC3 anymore, lol".
  2. Can I configure it manually in code or this is not supposed to work like that at all?

I could of course try to make it work by building a project in such config and see if it works, but if it is not supposed to work like that at all that would be just a waste of many hours. There is no documentation about it, even if it will somewhat work it will be a hell of a mess to try to make it work with DMA I presume.

So if anybody has done something similar or knows for a fact that it is not supposed to work would be nice to hear.

Oh and if somebody wonder why do it in a first place:
it would be nice to have "one channel" that utilizes dual mode to get 4.8 MSPS and the other just regular (from ADC3) with 2.4 MSPS. As opposed to having two simple channels at 2.4 MSPS.

Best Answer

In the application note you linked, page 9 says, in the context of dual mode:

In some devices, there are up to 3 ADCs: ADC1, ADC2 and ADC3. In this case ADC3 always works independently, and is not synchronized with the other ADCs

Unfortunately Cube can only expose a small subset of the capabilities of the MCU, and in this case it seems that the ADC options are lacking. This may be because there are relatively few parts that have three ADCs, so there's not as much impetus to support those modes. If you look at the reference manual, the MULTI field of the ADC common control register has the following options (page 429):

enter image description here

As to why Cube is showing three ADCs in dual mode, that's clearly a bug. Either it is configuring ADC1 and ADC2 for dual mode and leaving ADC3 alone, or it's configuring all three for triple mode. The only way to be sure may be to examine how the generated code is setting up the common control register.

You may want to raise this with ST, but in the mean time it seems like in order to get the configuration you want you will need to use the low level APIs as Tomas Li's answer suggests, or program the registers directly.