Skip to end of metadata
Go to start of metadata


Targeted HardwarephyBOARD-Zeta (i.MX7)
Targeted SoftwareRelease 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.     


ADC Access on the phyBOARD-Zeta

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 NameExpansion Connector Pin (X16)
X_ADC_IN0pin 85
X_ADC_IN1pin 87
X_ADC_IN2pin 89
X_ADC_IN3pin 91

 


Implementation Details

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. 

Configuring the device tree

To enable the ADC peripheral, you will need to modify the device tree. 

  1. 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/
  2. Add the following device tree node to enable the ADC1 peripheral:

    &adc1 {
           vref-supply = <&reg_vref_1v8>;
           status = "okay";
    };



  3. 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/
  4. 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>;
    };


Rebuilding the Device Tree

After the necessary modifications to the device tree, you will need to rebuild the device tree.

  1. Navigate to your build directory:

    cd <your BSP directory>/yocto_imx7/build
  2. Run the following command to rebuild the kernel:

    bitbake linux-phytec-fsl -f -c compile && bitbake linux-phytec-fsl
  3. 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.

  4. Remove the existing device tree from the SD card using the following command:

    rm /media/Boot\ imx7-p/imx7d-phyboard-zeta.dtb
  5. 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
  6. 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
  7. Unmount the SD card. 

Hardware setup

  1. Install the SD card on the i.MX7 board and configure the boot switch (SD1)

    SD Card (4-bit SD1 interface)



  2. Implement the following test circuit:

    DO NOT use an input voltage greater than 1.8V on any of the X_ADC_INx input channels.

     PDF     


  3. Start your favorite terminal software (such as Minicom or TeraTerm) on your host PC and configure it for 115200 baud, 8 data bits, no parity, and 1 stop bit (8n1) with no handshake.


  4. Apply power and press the power switch (S2) to boot Linux. This will boot the system so you can test the updates.


Testing ADC

Now that all the software and hardware setup has been complete we can test the changes.

  1. At the login prompt, enter "root" as the username. There is no required password.


  2. 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
  3. Here is an example of three measurements of roughly 1.8V (4096), 0.9V (2048) and 0.0V (0).