cancel
Showing results for 
Search instead for 
Did you mean: 

ADC sampling from ANA0/ANA1 via M4

ATringali
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Philippe Cherbonnel
ST Employee

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
Associate II

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

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 'Accept as Solution' on the reply which solved your issue or answered your question.
ATringali
Associate II

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

Antonio