cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use pin ANA0 and ANA1 as ADC.

xkun.1
Associate II

Hello,

I need use ANA0 and ANA1 as ADC because HW engineer connect ADC signal to those pins. But I don't konw how to config the devicetree. I think ANA0 and ANA1 pin are special pins. Please help me, Thank you.

Shaw.

1 ACCEPTED SOLUTION

Accepted Solutions
PatrickF
ST Employee

Hi,

please see https://wiki.st.com/stm32mpu/wiki/ADC_device_tree_configuration#DT_configuration_-28board_level-29

As ANA0 and ANA1 are directly connected to ADC input pins, there is no need of pinmux setting for those inputs.

ANA0 is directly connected to both ADC1 in0 and ADC2 in0

ANA1 is directly connected to both ADC1 in1 and ADC2 in1

So, a DT example using ANA0 on ADC1 and ANA1 on ADC2:

&adc {
	/* ADC1 & ADC2 common resources */
	pinctrl-names = "default";
	vdda-supply = <&vdda>;                       /* Example to supply vdda pin by using a PMIC regulator */
	vref-supply = <&vrefbuf>;                    /* Example to use VREFBUF (It needs to be enabled as well) */
	status = "okay";                             /* Enable ADC12 block */
	adc1: adc@0 {
		/* private resources for ADC1 */
		st,adc-channels = <0>;               /* ADC1 in0 channel is used */
		st,min-sample-time-nsecs = <10000>;  /* 10µs sampling time */
		status = "okay";                     /* Enable ADC1 */
	};
	adc2: adc@100 {
		/* private resources for ADC2 */
		st,adc-channels = <1>;               /* ADC2 in1 channel is used */
		st,min-sample-time-nsecs = <10000>;  /* 10µs sampling time */
		status = "okay";                     /* Enable ADC2 */
	};
};

If there is other ADCx_IN channels used on regular GPIOs pins, a pinmux will then be required for those pins (which need ADCx_PCSEL setup).

Regards.

Patrick

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

2 REPLIES 2
PatrickF
ST Employee

Hi,

please see https://wiki.st.com/stm32mpu/wiki/ADC_device_tree_configuration#DT_configuration_-28board_level-29

As ANA0 and ANA1 are directly connected to ADC input pins, there is no need of pinmux setting for those inputs.

ANA0 is directly connected to both ADC1 in0 and ADC2 in0

ANA1 is directly connected to both ADC1 in1 and ADC2 in1

So, a DT example using ANA0 on ADC1 and ANA1 on ADC2:

&adc {
	/* ADC1 & ADC2 common resources */
	pinctrl-names = "default";
	vdda-supply = <&vdda>;                       /* Example to supply vdda pin by using a PMIC regulator */
	vref-supply = <&vrefbuf>;                    /* Example to use VREFBUF (It needs to be enabled as well) */
	status = "okay";                             /* Enable ADC12 block */
	adc1: adc@0 {
		/* private resources for ADC1 */
		st,adc-channels = <0>;               /* ADC1 in0 channel is used */
		st,min-sample-time-nsecs = <10000>;  /* 10µs sampling time */
		status = "okay";                     /* Enable ADC1 */
	};
	adc2: adc@100 {
		/* private resources for ADC2 */
		st,adc-channels = <1>;               /* ADC2 in1 channel is used */
		st,min-sample-time-nsecs = <10000>;  /* 10µs sampling time */
		status = "okay";                     /* Enable ADC2 */
	};
};

If there is other ADCx_IN channels used on regular GPIOs pins, a pinmux will then be required for those pins (which need ADCx_PCSEL setup).

Regards.

Patrick

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.
Kevin HUBER
ST Employee

Hi @xkun.1​ 

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

Thanks,

Kevin

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.