The phyCORE-AM65x SOM brings out four 12-bit ADC analog input channels (ADC0_AIN[3:0]). On the development kit, you can access these signals through a PHYTEC Expansion board (PCM-957). This guide provides a walk-through for wiring up a circuit with a potentiometer to test all four channels.
Connect to the ADC
VREF for ADC channels is 1.8V
Channels ADC0_AIN[3:0] can be found on the PHYTEC Expansion Board pins listed in the table below.
|ADC Channel||Expansion Board Pin #|
You can wire up a test circuit with a potentiometer (see example below):
Expansion Board (PCM-957)
Set up Software Configuration
In order to be accessible in Linux, the ADC Channels need to be configured in the Linux device tree. PHYTEC has provided a sample device tree overlay in the boot directory of the root file system, which configures expansion connector interfaces used in this Peripheral Guide. To enable this device tree overlay:
- The device tree overlay is set in U-Boot.
- Power on the device and immediately hit any key to enter U-Boot. (Approximately three seconds are allotted for the user to hit any key in order to halt autoboot of Linux.)
- Clear the "default_overlays" variable and modify the "extra_overlays" variable to point to the sample dtbo: "k3-am65xx-phytec-expansion-sample.dtbo". The "default_overlays" variable needs to be cleared because it is set to k3-am65xx-phytec-lcd-018.dtbo which conflicts with the sample.
setenv default_overlays setenv extra_overlays k3-am65xx-phytec-expansion-sample.dtbo saveenv
To exit U-Boot and continue booting into Linux, type boot
The Expansion Sample overlay k3-am65xx-phytec-expansion-sample.dtbo conflicts with the LCD-018 overlay due to the PWM being used for backlight in the LCD-018. Make sure to disconnect the display when using this overlay before powering on the development kit.
Read the ADC
You will be able to read each channel from the Linux command line. Below is a mapping of the ADC channel and corresponding device in Linux.
|ADC Channel||Signal Name|
This example shows how to read incoming data on ADC0_AIN0:
The ADC registers are 12 bits which will read from 0 to 4095. From the ADC reading you can calculate the voltage at the pin with the following formula:
The potentiometer was adjusted and a couple readings were taken from Linux to calculate the voltage. See the below example.
root@am65xx-phycore-kit:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 0 root@am65xx-phycore-kit:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 2092 root@am65xx-phycore-kit:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 4095
Revert to the Default Software Configuration
This guide requires disabling the LCD-018 and enabling a sample expansion overlay. In order to revert back to the default overlay settings, the following needs to be run in U-Boot. (After application of power, approximately three seconds are allotted for the user to hit any key in order to halt autoboot of Linux.)
To enter U-Boot:
Power on or reset (S1) the hardware
Hit any key within 3 seconds to halt autoboot
env default -f -a saveenv