October 29, 2021
Editor’s Note: This content is republished from the MicroZed Chronicles, with permission from the author.
Recently we examined Industrial Input and Output drivers in PetaLinux when using an ADC on a Pmod. Of course, all Xilinx devices also have an internal XADC/Sysmon which can measure the internal device voltage rails and temperature. XADC/Sysmon is also capable of monitoring several external input voltages. Depending on if the dedicated differential input is used or one of the 16 auxiliary inputs is used, the sampling rate is either 1000 Kilo Samples Per Second (KSPS) or 250 KSPS.
This provides potentially up to 17 analog signals which can be sampled by the XADC so being able to use these via IIO in our embedded Linux application would be very useful.
The XADC is always included when we build the embedded Linux solution; however, only the internal voltages and temperatures are enabled by default. To be able to use the dedicated or auxiliary inputs, we need to update both the Vivado design and the device tree.
To get started, we are going to use the same base design created for the MiniZed in article 413. I added in the XADC IP block to this block design and configured the auxiliary channels to support those used on the Minized.
When examining the schematics for the MiniZed, we can see that Aux0, Aux8 and Aux1 are connected to the Arduino inputs A0 – A5. These are bipolar inputs with the P and N signals broken out the connector.
Within Vivado, we can then configure the XADC to enable only the desired channels.
Once this has been configured, we are able to compile the design, generate the bit stream, and export the XSA.
With the XSA available, we can re-use the previous PetaLinux project used for the original IIO example and update the hardware specification using the new hardware configuration.
After the project has been updated with the XSA, the next step is to update the device tree under the meta-user layer of the project.
The change we need to make to the device tree is simple. We need to enable the AUX channels in the XADC binding as below. When enabling the channels, channel 0 corresponds to the dedicated inputs VP/VN while the AUX channels are 1 to 16. In this case we are enabling channels, 1,2 and 9.
adc@f8007100 {
xlnx,channels {
#address-cells = <1>;
#size-cells = <0>;
channel@1 {
reg = <1>;
};
channel@2 {
reg = <2>;
};
channel@9 {
reg = <9>;
};
};
};
Once the device tree has been updated, the next step is to build the PetaLinux image and boot the MiniZed with it.
Once the boot completes and the embedded Linux solution is running, we can check the sys/bus/iio/devices/iio:device1 to see the number of channels available.
Under the XADC, we will now not only see the internal voltages and temperature but also the three external voltage inputs enabled in the Vivado design and the device tree.
In upcoming blogs, we will look at how we can develop the software applications using these inputs.