ADC overview
The ADC subsystem includes signal multiplexing and a voltage analog-to-digital converter (VADC). It is a multiplexed network that routes internal and external signals to the VADC.
ADC module hardware architecture

Supported ADC channels
The module supports the following ADC channels:
| Interface | Pin no. | Pin name | PM4250 pin no. | Voltage domain | MPM interrupt | Pin description |
|---|---|---|---|---|---|---|
| ADC | 128 | ADC0 | GPIO4 | 1.8 V | - | PMU_GPIO04 |
| ADC | 185 | ADC1 | GPIO7 | 1.8 V | - | PMU_GPIO07 |
ADC interface location
The location of the ADC interfaces on the smart single-board computer is shown below:
ADC location on the smart single-board computer
ADC node usage example
The ADC nodes are mainly used to read the ADC values at the corresponding input nodes.
Usage
Test method: use an adjustable DC power supply as the input signal source. Connect the positive terminal of the power supply to the ADC0 or ADC1 pin, and connect the power supply ground (GND) to the development board's GND.
- ADC0: connected to GPIO4, corresponding node
in_voltage_adc_gpio4_input, supported input voltage range is approximately 0–5.25 V. - ADC1: connected to GPIO7, corresponding node
in_voltage_adc_gpio7_input, supported input voltage range is approximately 0–5.25 V.
After setting the DC power output to an arbitrary voltage, you can read the returned ADC value (in μV) using the following commands:
adb shell
cd /sys/bus/iio/devices/iio:device0
cat in_voltage_adc_gpio4_input
cat in_voltage_adc_gpio7_input
Example of ADC read output
Test code
The following sample code demonstrates how to read the ADC value in an application. It opens the ADC node file, reads the raw ADC value (in μV), and converts it to an integer for further processing.
Click to expand/collapse: ADC read test code (can be compiled with NDK)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main()
{
int fd = -1;
int adc_value;
char buff[64] = {0};
// Open the ADC node file (ADC0 corresponds to GPIO4)
fd = open("/sys/bus/iio/devices/iio:device0/in_voltage_adc_gpio4_input", O_RDONLY);
if(fd < 0){
perror("open error\n");
return fd;
}
// Read the ADC value
int n_read = read(fd, buff, sizeof(buff));
if(n_read < 0) {
perror("read error\n");
close(fd);
return -1;
}
// Convert the read string to an integer value (unit: μV)
adc_value = atol(buff);
printf("read %d bytes, content: %s\n", n_read, buff);
printf("ADC value: %d μV\n", adc_value);
close(fd);
return 0;
}
Code description:
- Uses the
open()function to open the ADC node file/sys/bus/iio/devices/iio:device0/in_voltage_adc_gpio4_input. - Uses the
read()function to read the raw ADC value (string format, unit: μV). - Uses the
atol()function to convert the string to a long integer. - The read ADC value is in microvolts (μV) and can be converted to a voltage value as needed.
Compilation and execution:
# Compile with NDK
# Push the compiled executable to the device and run it
adb push test_adc /data/local/tmp/test_adc
adb shell "chmod +x /data/local/tmp/test_adc"
adb shell "/data/local/tmp/test_adc"
Test data
ADC pin specifications
The ADC pins on the module are defined as follows:
| Interface | Module pin no. | Module pin name | Module I/O | NET name (alternate function) | Description |
|---|---|---|---|---|---|
| ADC | 128 | ADC0 | I | ADC0 | 1) Connector input voltage range: 0–5.25 V. 2) Divider resistors: RH = 18 kΩ, RL = 10 kΩ. 3) Voltage on ADC pin = connector input voltage (J0403) × (10/28). 4) Example: for an input of 3 V, the ADC pin voltage should be 3 V × 10/28 ≈ 1.0714 V. |
| ADC | 185 | ADC1 | I | ADC1 | Same electrical characteristics as ADC0 (0–5.25 V input range, RH = 18 kΩ, RL = 10 kΩ, ADC pin voltage = Vin × 10/28). |
ADC0 test data
| Voltage source | ADC0 (μV) | Theoretical value (V) |
|---|---|---|
| 1.8 V | 638408 | 1.8 V×10/28 = 0.642857 |
| 3 V | 1066414 | 3 V×10/28 = 1.07143 |
| 5 V | 1784623 | 5 V×10/28 = 1.78571 |
ADC1 test data
| Voltage source | ADC1 (μV) | Theoretical value (V) |
|---|---|---|
| 1.8 V | 640549 | 1.8 V×10/28 = 0.642857 |
| 3 V | 1069269 | 3 V×10/28 = 1.07143 |
| 5 V | 1789814 | 5 V×10/28 = 1.78571 |