We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 

Adam Taylor’s MicroZed Chronicles, Part 107: Combining XADC and Interrupts with Real-World Signals

Xilinx Employee
Xilinx Employee
0 8 189K


By Adam Taylor


Now that we have determined the latency from interrupt assertion to ISR execution on the Xilinx Zynq SoC, we can define the hardware we want to pull into SDSoC from Vivado. Knowing and designing for the latency means we can be sure that we never miss an XADC sample. If we had been unable to determine the latency, we would have been forced to develop a more complicated acquisition architecture in Vivado. Luckily, we have significant margin.


Recall that in blog 104 in this series, we examined XADC use in the real world. You will remember that we can sample at 961.5385Ksamples/sec using a 100MHz AXI clock frequency. That means a new sample and corresponding interrupt will occur every 1.04 Microseconds. It is therefore simple to show that we have sufficient margin given the measured ISR latency. (Between you and me, I was pretty confident we’d be OK but actually measuring the timing helps when we look at more complex designs.)


Our next step is to create our base design using Vivado. To do this, I will remove the first timer and substitute an XADC component. I will leave the second AXI Timer in place. These timers are very useful things to have in our embedded systems.


In the system shown below, I have connected the ip2intc_irpt signal from the XADC to the Core0_nIRQ private interrupt of core 0. This means the interrupt is only seen by the first core and not the second as it is connected to a private peripheral interrupt.







I inted to use the dedicated Vp / Vn input signals and not the auxiliary inputs. We can easily put these into the design by right clicking on the Vp_Vn port on the XADC and selecting “make external.” This step adds the port as you see above. These are dedicated pins. Rather helpfully, you do not need to create an XDC constraints file to define their location.


At this point we can build the hardware and generate the bit file. I also want to double check that the hardware is going to function correctly. With this in mind, I exported the hardware to SDK and wrote a simple program that captures the input signal. I wanted to be sure I had no issues before we pull the design into SDSoC.


I’ve made the code for this instalment available on the GitHub repository. As we want to talk to the XADC over the AXI interface and not the DevC interface (see blog 62 ) we use the Sysmon.h drivers. The code performs the following steps:


  1. Initialize the XADC using the Sysmon drivers
  2. Set the sequencer to single-channel mode
  3. Set the single-channel parameters for the Vp/Vn input channel: unipolar mode, not event driven, standard acquisition, number of cycles
  4. Clear the alarms
  5. Apply the calibration
  6. Enable an interrupt to occur at the end of the conversion—not sequence—because for a single channel, there is no sequence.
  7. Capture 64 samples from the XADC; disable interrupts; output the 64 samples over the Stdout channel

With this completed I connected a Digilent Analog Discovery module to the XADC Vp / Vn pins, which are broken out on the ZedBoard J2 pins 1 (Vn – GND) and 2 (Vp – Signal). You can see schematic of the pinout below and a picture of the MicroZed board and Analog Discovery Module on my desk.









The first thing to do was check that the sampled value output from the XADC was correct. In this case, the XADC is configured as unipolar, so for 0v input we should get an XADC value of 0x000 and for 1.0V (the maximum input value) we should get a value of 0xFFF. Between the two extremes of course it should be linear.


With the expected behavior confirmed, the next step was to configure the Analog Discovery module to output a sine wave and capture that signal with the XADC. The results appear below:







This waveform proves the hardware build is correct and that we will not be wasting time creating an SDSoC platform.





If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.




  • First Year E Book here
  • First Year Hardback here.


 MicroZed Chronicles hardcopy.jpg




  • Second Year E Book here
  • Second Year Hardback here



 MicroZed Chronicles Second Year.jpg




You also can find links to all the previous MicroZed Chronicles blogs on my own Web site, here.






Tags (3)