An Analog-to-Digital Converter (ADC) is a device that translates an analog voltage to a digital value that a microprocessor can understand.

The NXP system-on-module has one ADC controller which is a 12-bit 4-channel with 1MS/s ADC.

The ADC channels meet the 12-bit single-ended accuracy specifications.

Available ADC pins

On the ConnectCore 93:

  • ADC_IN0 to ADC_IN3 channels are available at the LGA pads. Check the Hardware reference manuals for information about pads and ADC channels.

On the ConnectCore 93 Development Kit:

  • All four ADC channels are accessible on the expansion connector J48:

    • ANA0 (ADC1 channel 0)

    • ANA1 (ADC1 channel 1)

    • ANA2 (ADC1 channel 2)

    • ANA3 (ADC1 channel 3)

Kernel configuration

You can manage the i.MX93 ADC driver support through the following kernel configuration option:

  • IMX93 ADC driver (CONFIG_IMX93_ADC)

This option is enabled as built-in on the default ConnectCore 93 kernel configuration file.

Kernel driver

The ADC driver is located at:

File Description

drivers/iio/adc/imx93_adc.c

i.MX93 IMX93 ADC driver

Device tree bindings and customization

i.MX93 ADC interface

i.MX93 device tree
adc1: adc@44530000 {
	compatible = "nxp,imx93-adc";
	reg = <0x44530000 0x10000>;

	interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>,
			<GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH>,
			<GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>,
			<GIC_SPI 268 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clk IMX93_CLK_ADC1_GATE>;
	clock-names = "ipg";
	status = "disabled";
};

On the ConnectCore 93 Development Kit.

ConnectCore 93 Development Kit device tree
/* ADC - 4 channels available on expansion connector */
&adc1 {
	vref-supply = <&reg_vref_1v8>;
	status = "okay";
};

Voltage reference

The ADC controller uses an internal 1.8V.

Formula

The value read on the ADC inputs responds to the formula:

\$V_(READ) = (V_(IN) * 4095) / V_(REF)\$

where:

  • VREAD is the digital value read

  • VIN is the analog input voltage

  • VREF is the ADC voltage reference

Using the ADCs

The ADC driver is designed as standard Industrial I/O (IIO) device drivers that can be accessed from the sysfs or from user applications.

Sysfs access

The ADC driver creates the corresponding device entries in the IIO sysfs directory (/sys/bus/iio/devices). You can access the ADC values through the sys file system:

Reading an ADC through the sysfs
# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
37

The returned value is a decimal number with the result of the conversion. In the example for the i.MX93 ADC:

\$V_(READ) = (V_(IN) * 4095) / V_(REF) -> V_(IN) = (V_(READ) * V_(REF)) / 4095 -> V_(IN) = (37 * 1.8) / 4095 = 0.016 V\$

To help with the calculation, multiply the read value by the value contained in the in_voltage_scale descriptor:

Reading voltage scale through the sysfs
# cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
0.439453125

\$V_(IN) = V_(READ) * "<in_voltage_scale>" = 37 * 0.439453125 = 16.259 mV = 0.016 V\$

Sample application

An example application called apix-adc-example is included in the dey-examples-digiapix recipe (part of dey-examples package) of the meta-digi layer. This application shows how to access the ADCs using Digi APIx library on the ConnectCore 93 platform.

Go to GitHub to see the application instructions and source code.

See ADC API for more information about the ADC APIx.