An Analog-to-Digital Converter (ADC) is a device that translates an analog voltage to a digital value that a microprocessor can understand.
The STMicroelectronics system-on-module has three ADC controllers, each with up to 20 channels. The ADC controllers are 12-bit successive approximation analog-to-digital converters.
Available ADC pins
On the ConnectCore MP25:
-
Dedicated analog pads
ANA0
andANA1
are available at the LGA pads.-
ANA0
(ADC1/ADC2/ADC3 channel 0) -
ANA1
(ADC1/ADC2/ADC3 channel 1)
-
-
A number of ADC channels are available at outer LGA ring and LGA pads, multiplexed with other functions. Check the Hardware reference manuals for information about pads and ADC channels.
On the ConnectCore MP25 Development Kit:
-
ANA0
(ADC1/ADC2/ADC3 channel 0) is accessible on the Flexible IO expansion connector J8 -
ANA1
(ADC1/ADC2/ADC3 channel 1) is accessible on the Flexible IO expansion connector J8 -
GPIOG 1 (ADC1 channel 6) is accessible on
MIKROBUS_ADC
line, connector J39 -
GPIOG 2 (ADC2 channel 2) is accessible on
MIKROBUS_RST
line, connector J39
Kernel configuration
You can manage the STM32MP25 ADC drivers support through the following kernel configuration options:
-
STM32 ADC core driver (
CONFIG_STM32_ADC_CORE
) -
STM32 ADC driver (
CONFIG_STM32_ADC
)
These options are enabled as built-in on the default ConnectCore MP25 kernel configuration file.
Kernel driver
The ADC drivers are located at:
File | Description |
---|---|
STM32MP25 ADC core driver |
|
STM32MP25 ADC driver |
Device tree bindings and customization
The STM32MP25 ADC device tree binding is documented at
Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml
.
The device tree must contain entries for:
-
The ADC interfaces
-
The enabled channels
-
The IOMUX (for ADC channels on non-dedicated pads)
STM32MP25 ADC interfaces and channels
The STM32MP25 device tree defines:
-
The three ADC interfaces as child nodes of the ADC core
-
The channels of each interface as child nodes inside each ADC interface
adc_12: adc@404e0000 {
compatible = "st,stm32mp25-adc-core";
[...]
status = "disabled";
adc1: adc@0 {
compatible = "st,stm32mp25-adc";
[...]
status = "disabled";
channel@14 {
reg = <14>;
label = "vrefint";
};
};
adc2: adc@100 {
compatible = "st,stm32mp25-adc";
[...]
status = "disabled";
channel@14 {
reg = <14>;
label = "vrefint";
};
channel@15 {
reg = <15>;
label = "vddcore";
};
channel@17 {
reg = <17>;
label = "vddcpu";
};
channel@18 {
reg = <18>;
label = "vddgpu";
};
};
};
adc_3: adc@404f0000 {
compatible = "st,stm32mp25-adc-core";
[...]
status = "disabled";
adc3: adc@0 {
compatible = "st,stm32mp25-adc";
[...]
status = "disabled";
channel@14 {
reg = <14>;
label = "vrefint";
};
channel@15 {
reg = <15>;
label = "vddcore";
};
channel@17 {
reg = <17>;
label = "vddcpu";
};
channel@18 {
reg = <18>;
label = "vddgpu";
};
};
};
ConnectCore MP25 Development Kit ADC interfaces and channels
-
ADC1/ADC2/ADC3 channels 0 and 1 are enabled. These channels are available at dedicated analog pads
ANA0
andANA1
. -
ADC1 channel 6 is enabled on GPIO
PG1
.
&adc_12 {
vref-supply = <&external_vref>;
vdda-supply = <&scmi_vdda18adc>;
pinctrl-names = "default";
pinctrl-0 = <&ccmp25_adc_pins>;
status = "okay";
adc1: adc@0 {
status = "okay";
channel@0 {
reg = <0>;
/* 16.5 ck_cycles sampling time */
st,min-sample-time-ns = <400>;
};
channel@1 {
reg = <1>;
/* 16.5 ck_cycles sampling time */
st,min-sample-time-ns = <400>;
};
channel@6 {
reg = <6>;
/* 16.5 ck_cycles sampling time */
st,min-sample-time-ns = <400>;
};
};
};
[...]
&pinctrl {
ccmp25_adc_pins: ccmp25_adc_pins-0 {
pins {
pinmux = <STM32_PINMUX('G', 1, ANALOG)>;
};
};
};
Select and configure an ADC channel
Follow these steps to configure ADC channels on your custom design:
-
Identify the pins you want configured as ADC on the Hardware reference manuals. Pins that are ADC-capable list a additional function like
ADCn_INPx
, where n is the ADC interface and x the channel. -
Add a
channel@x
as a subnode of the ADCn interface, and propertyreg = <x>;
inside. -
Configure the IOMUX of the pads to operate as
ANALOG
inputs. (PadsANA0
andANA1
are dedicated ADC pins and do not need any IOMUX configuration.)
For example, pad PG1
of the CPU has additional function ADC1_INP6
.
This pad is available on the ConnectCore MP25 Development Kit mikroBUS™ socket connector.
&adc12 {
status = "okay";
channel@6 {
reg = <6>;
label = "PG1";
st,min-sample-time-nsecs = <400>;
};
};
&pinctrl {
ccmp25_adc_pins: ccmp25_adc_pins-0 {
pins {
pinmux = <STM32_PINMUX('G', 1, ANALOG)>;
};
};
};
Voltage reference
The ADC block supports the following voltage references:
-
External voltage reference supplied through
VREF+
pad.
External voltage reference
You can use an external voltage reference for the ADC. This external voltage reference must be between the limits:
-
Min: 1.1 V
-
Max: 1.8 V
To use an external voltage reference:
-
Add a fixed regulator node for the external regulator, with its voltage: For example:
/ { regulators { /* * External regulator for ADC. * This regulator DOES NOT exist on the DVK. It is only * a helper for testing the ADC channels. * To make use of it, you need to supply externally the * configured voltage to the VREF+ pad. * * NOTE: This is incompatible with using the internal VREFBUF * regulator, which outputs a voltage at VREF+ pad. */ external_vref: regulator@99 { reg = <99>; compatible = "regulator-fixed"; regulator-name = "external-vref"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; }; }; };
-
Set the property
vref-supply
of the ADC node to use the external regulator:&{adc-node} { vref-supply = <&external_vref>; };