Showing results for 
Search instead for 
Did you mean: 

Usage of this same ADC pin on two ADC instances


Hello, I am working on STM32F7x uC and I want to use one GPIO pin, e.g. PA3 as analog input. However, value from analog input should be read both by ADC1 and ADC2. CubeMX allows me that configuration and it should work. However, when I deinitialize only ADC1 then ADC2 stops work too. The reason is fact that generated: HAL_ADC_MspDeInit() function just deinitializes PA3 pin and it does not take into account that the other instance of ADC uses this pin as well.

is it kind of limitation of CubeMX solution? or Do I miss something else and there is a limitation of hardware and one GPIO pin cannot be used by two (or more) instances of ADC simultaneously?

Best regards and thanks in advance for any tips.





ST Employee

Hello @Tomnow1

>>here is a limitation of hardware and one GPIO pin cannot be used by two (or more) instances of ADC simultaneously

It is possibleto use two ADCs with the same pin as an analog input: IO is in analog mode and shared (not alternate function)

If you're using more than one ADC instance, you might want to modify the generated HAL_ADC_MspDeInit() code to avoid calling __HAL_RCC_ADC_CLK_DISABLE, or at least be aware that all ADCs use the same clock and disabling the clock will reset all ADCs. so this is quite predictable... 


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

ST Employee

Hello @Tomnow1,

No HW limitation, but probably a feature still not covered by CubeMx.

For this example as workaround, you might comment call to HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3); in HAL_ADC_MspDeInit() function in order to avoid "deinitialize the GPIOx peripheral registers to their default reset values."


Best regards


Hello, thanks for your feedback. It's clear to me that I can handle it myself by modifying generated code. Thank you to make me sure about that.


Best regards