04 - ADC Acquisition Application
This chapter describes the ADC acquisition application example on the Pico-G1 expansion board — adc_display. It demonstrates how to sample analog voltages with the chip's built-in LSADC (12-bit SAR ADC) and display the voltage value in real time on a TFT screen. It is a fundamental example for learning analog signal acquisition.
The application source code lives in the SDK directory source/app/04_adc_display/, providing a complete ADC character-device implementation.
1 Application Overview
1.1 Features
- LSADC sampling: demonstrates voltage sampling with the chip's built-in 12-bit ADC
- Real-time display: shows the voltage value and raw ADC value on a TFT screen
- High-precision display: supports millivolt-level voltage precision
- Automatic calibration: supports VREF voltage reference configuration
1.2 Technical Specifications
| Parameter | Value |
|---|---|
ADC resolution | 12-bit (0~4095) |
Sampling channel | CH1 (GPIO1_1) |
VREF voltage | 1.8V (default, configurable) |
Input range | 0~VREF (≤ 3.3V) |
Sampling mode | CONTINUOUS |
Refresh interval | 100ms (configurable) |
1.3 Hardware Connection
| Signal | On-board GPIO | Physical pad | Description |
|---|---|---|---|
| AO | GPIO1_1 | iocfg_reg21 @ 0x12090004 | ADC input channel 1 |
| VCC | 1.8V | — | Reference voltage (must be ≤ 3.3V) |
| GND | GND | — | Ground |
2 Build and Deployment
2.1 Building the Application
export PATH=$PATH:<SDK>/tools/linux/toolchains/arm-gcc12.2.0-linux-uclibceabi/bin
cd <SDK>/source/app/04_adc_display
make2.2 Running the Application
scp adc_display root@<board-IP>:/usr/bin/
ssh root@<board-IP} '/usr/bin/adc_display'3 Expected Output
3.1 Console output
/mnt # ./adc_display
[adc] pad 0x12090004 -> 0x00001004
[spi] pad 0x100C0028 -> 0x00001004
[spi] pad 0x100C002C -> 0x00001004
[spi] pad 0x100C0030 -> 0x00001000
[spi] pad 0x100C0020 -> 0x00001005
[spi] pad 0x100C001C -> 0x00001005
[spi] opening /dev/spidev2.0 ...
[spi] spidev opened, fd=3
[spi] spidev mode/bits/speed set (MODE3/8b/24MHz)
[spi] chardev request DC @ /dev/gpiochip4 line 5 ...
[spi] chardev request RES @ /dev/gpiochip4 line 4 ...
[spi] chardev request CS @ /dev/gpiochip5 line 1 ...
[spi] chardev-verify: DC=0(expect0) RES=1(expect1) CS=1(expect1) ==> OK(chardev 真驱动了引脚)
[spi] spi_hal_init done
[tft] init: SLPOUT
[tft] init: SLPOUT +120ms ok
[tft] init: config cmds ok
[tft] init: DISPON
[tft] init: DISPON ok
[tft] init: clear-flush start
[tft] flush #1 start
[tft] flush #1 done
[tft] init: clear-flush done
[adc] /dev/lsadc 不存在,自动 insmod xm_lsadc.ko ...
raw=4095 V=3.300
[tft] flush #2 start
[tft] flush #2 done3.2 TFT screen display

4 Troubleshooting
| Problem | Possible cause | Solution |
|---|---|---|
| /dev/lsadc missing | LSADC driver not loaded | The program loads xm_lsadc.ko automatically |
| Abnormal readings | Wrong VREF configuration | Modify the ADC_VREF_MV parameter |
| Fluctuating values | Unstable input signal | Add a filtering circuit |
