2022-01-23 11:59 AM
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
Solved! Go to Solution.
2022-01-24 05:18 AM
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
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.
2022-01-24 03:02 AM
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
2022-01-24 03:27 AM
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
2022-01-24 05:18 AM
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
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.
2022-01-24 08:24 AM
Thank you very much. That is pretty much what I wanted to be confirmed.
Antonio