Targeted Hardware | phyBOARD-Zeta (i.MX7) |
Targeted Software | Release PD17.2.0 (Coming Soon) |
Date |
|
This article will demonstrate how to set up and access X_ADC_IN0 on the phyBOARD-Zeta (i.MX7). Software release PD17.1.1 can be modified to enable the ADC1 channel following the instructions in this guide. Support for the ADC is planned to be incorporated in the PD17.2.0 software release.
The ADC channel 1 pins on the phyCORE-i.MX7 are brought out to the expansion connector (X16) on the phyBOARD-Zeta as X_ADC_INx. This guide uses signal X_ADC_IN0 as an example, but the below table provides the location where alternative ADC input signals can be accessed.
Net Name | Expansion Connector Pin (X16) |
---|---|
X_ADC_IN0 | pin 85 |
X_ADC_IN1 | pin 87 |
X_ADC_IN2 | pin 89 |
X_ADC_IN3 | pin 91 |
Software release PD17.1.1 does not enable the ADC by default. The steps below can be used as a guide to enable the ADC, rebuild the device tree, and deploy/test the changes. Please note that the next BSP Release, PD17.2.0 will support ADC and these steps will not be required.
To enable the ADC peripheral, you will need to modify the device tree.
Using a text editor, open the file called 'imx7d-phyboard-zeta.dts' located in the following directory:
<your BSP directory>/yocto_imx7/build/tmp/work/imx7d_phyboard_zeta-poky-linux-gnueabi/linux-phytec-fsl/4.1.15+git_v4.1.15-phy2-r0/git/arch/arm/boot/dts/ |
Add the following device tree node to enable the ADC1 peripheral:
&adc1 { vref-supply = <®_vref_1v8>; status = "okay"; }; |
Next you want to edit the 'imx7d-pba-c-09.dtsi' file located in the same directory:
<your BSP directory>/yocto_imx7/build/tmp/work/imx7d_phyboard_zeta-poky-linux-gnueabi/linux-phytec-fsl/4.1.15+git_v4.1.15-phy2-r0/git/arch/arm/boot/dts/ |
Add the following device tree node under the regulators section to enable the 1v8 voltage reference:
reg_vref_1v8: regulator@2 { compatible = "regulator-fixed"; reg = <2>; regulator-name = "vref-1v8"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; }; |
After the necessary modifications to the device tree, you will need to rebuild the device tree.
Navigate to your build directory:
cd <your BSP directory>/yocto_imx7/build |
Run the following command to rebuild the kernel:
bitbake linux-phytec-fsl -f -c compile && bitbake linux-phytec-fsl |
Mount an SD card with an existing PD17.1.1 image. If you do not have an SD card with image PD17.1.1, follow steps 1 through 3 in the 'Booting with Pre-built Images' section of the Quickstart guide.
Remove the existing device tree from the SD card using the following command:
rm /media/Boot\ imx7-p/imx7d-phyboard-zeta.dtb |
Navigate to the directory on your build machine where the compiled images are deployed:
cd <your BSP directory>/build/tmp/deploy/images/imx7d-phyboard-zeta |
Copy and rename the device tree to the SD card using the following command:
cp zImage-imx7d-phyboard-zeta.dtb /media/user/Boot\ imx7d-/imx7d-phyboard-zeta.dtb; sync |
Unmount the SD card.
SD Card (4-bit SD1 interface)
Implement the following test circuit:
DO NOT use an input voltage greater than 1.8V on any of the X_ADC_INx input channels. |
Now that all the software and hardware setup has been complete we can test the changes.
You should now be able to quickly test/read the ADC register by using the following command:
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw |