Skip to main content
ATringali
Associate II
January 23, 2022
Solved

ADC sampling from ANA0/ANA1 via M4

  • January 23, 2022
  • 4 replies
  • 2551 views

Hi,

I have some doubts about how I could sample from the ANA0/ANA1 pins of an STM32MP1 CPU from inside the M4 firmware via HAL. I would like to programmatically switch between these two pins.

Sampling from ADC_CHANNEL_0 seems to work, so I guess it is connected to ANA0. But sampling from ANA1 / ADC_CHANNEL_1 does not.

Could anybody point me to some documentation or, event better, example source code?

Thank you,

Antonio

This topic has been closed for replies.
Best answer by PatrickF

Hi @ATringali​ ,

you should refer to product datasheet (e.g. DS12505 for STM32MP157C/F), on ANA0 and ANA1 line in "STM32MP157C/F pin and ball definitions" table, you will see the mapping with ADCs

  • ANA0 is connected to ADC1_INP0, ADC2_INP0, ADC1_INN1, ADC2_INN1
  • ANA1 is connected to ADC1_INP1, ADC2_INP1

See also product reference manual (e.g. RM0436 for STM32MP157), "ADC1 connectivity" and "ADC2 connectivity" in ADC section.

ADCx_INPy stand for CHANNELy (y from 0 to 19) of ADCx (x either 1 or 2).

Note that ADCx_INNy are for differential input of CHANNELy (if differential mode is enabled).

Regards.

4 replies

Philippe Cherbonnel
ST Employee
January 24, 2022

Hello @ATringali​ ,

The common way to convert multiple ADC channels is to use ADC and DMA: configure the 2 channels in ADC sequencer and DMA to transfer each ADC conversion data.

There are no examples yet in STM32MP1 FW package, but can find one in STM32L5 FW package (ADC and DMA peripherals of MP1 and L5 are different, but main configuration principles are similar).

Using ADC HAL driver:

...\Firmware\Projects\NUCLEO-L552ZE-Q\Examples\ADC\ADC_MultiChannelSingleConversion

Best regards

Philippe

ATringali
ATringaliAuthor
Associate II
January 24, 2022

Hello Philippe,

thank you for your kind answer.

What I do not grasp is the mapping.

Is channel 0 associated to pin ANA0 and channel 1 associated to pin ANA1?

Antonio

PatrickF
PatrickFBest answer
ST Employee
January 24, 2022

Hi @ATringali​ ,

you should refer to product datasheet (e.g. DS12505 for STM32MP157C/F), on ANA0 and ANA1 line in "STM32MP157C/F pin and ball definitions" table, you will see the mapping with ADCs

  • ANA0 is connected to ADC1_INP0, ADC2_INP0, ADC1_INN1, ADC2_INN1
  • ANA1 is connected to ADC1_INP1, ADC2_INP1

See also product reference manual (e.g. RM0436 for STM32MP157), "ADC1 connectivity" and "ADC2 connectivity" in ADC section.

ADCx_INPy stand for CHANNELy (y from 0 to 19) of ADCx (x either 1 or 2).

Note that ADCx_INNy are for differential input of CHANNELy (if differential mode is enabled).

Regards.

In order to give better visibility on the answered topics, please click on 'Best Answer' on the reply which solved your issue or answered your question.Tip of the day: Try Sidekick STM32 AI agent
ATringali
ATringaliAuthor
Associate II
January 24, 2022

Thank you very much. That is pretty much what I wanted to be confirmed.

Antonio