UPGRADE YOUR BROWSER

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!

Adam Taylor’s MicroZed Chronicles Part 43: XADC Alarms and Interrupts

by Xilinx Employee ‎07-28-2014 10:50 AM - edited ‎01-07-2016 04:39 PM (324,999 Views)

By Adam Taylor

 

 

I planned to continue our look at operating system for the Zynq SoC in this blog. However due to a few questions asked last week about the Zynq SoC’s XADC, interrupts, and alarms, I thought it would be a good idea to quickly look at these and see how we can use them within a system.

 

The Zynq SoC’s ability to monitor its own supply voltages and its on-chip operating temperature is really interesting and we can use this ability during system commissioning to verify the initial supply voltages and operating temperature. We can then check periodically to ensure that these parameters remain within the targeted operating ranges throughout the testing and operation of our design. We can also use this facility during system operation as a kind of prognostic to determine if the Zynq SoC’s environment has a problem that could eventually induce a failure (e.g. a slowly drifting power supply).

 

The Zynq SoC has a number of maskable interrupts that can interrupt the two on-chip ARM Cortex-A9 MPCore processors should an alarm parameter go outside of user-defined maximum or minimum parameter settings. The XADC has its own dedicated interrupt, shared by both processors on IRQ 39 as this extract from the Zynq TRM (Technical Reference Manual) shows:

 

 

Image 1.png 

 

 

These alarm parameters can be set during the configuration of the XADC within Vivado as show below:

 

 

Image 2.png

 

 

They can also be set during execution of the software using the xadc_ps.h functions provided. For instance:

 

 

XAdcPs_SetAlarmThreshold(XADCInstPtr, XADCPS_ATR_TEMP_LOWER,(TempRawData));

 

 

The XADC provides a number of alarm output signals that can be connected to other logic modules implemented in the Zynq SoC’s PL (programmable logic). These logic modules can initiate an action should an alarm occur. They can also drive external indicators—LEDs for instance—which could be located on a front panel to show equipment status. This is especially useful for providing visual warnings of temperature should the system fan fail, etc.

 

 

Image 3.png

 

 

These alarms (there are seven in total, see the table from TRM above) can be enabled using the function call with the appropriate mask, as supplied by xadcps_hw.h. If more than one alarm is required, then OR them together.

 

 

XAdcPs_SetAlarmEnables(XADCInstPtr, XADCPS_CFR1_ALM_TEMP_MASK);

 

 

Once we’ve enabled the alarm, we enable the interrupt as well using the appropriate function call, again using the masks provided by xadcps_hw.h. To enable more than one interrupt at a time, OR them together:

 

 

XAdcPs_IntrEnable(XADCInstPtr,XADCPS_INTX_ALM0_MASK);

 

 

With this in mind, I set about creating a simple project in Vivado which consists of the Zynq PS connected to the XADC via the AXI interface. For this example, I do not use any external analog inputs but do use the device’s internal temperature measurement, which is part of the Zynq XADC.

 

 

 Image 4.png

 

 

The software configures the XADC to interrupt the processor should the temperature go above or below the initial power-up reading, plus or minus a few degrees. In reality we would not want such a tight tolerance on the operating temperature.  However this is a great application to demonstrate the XADC interrupt because the self-heating during the Zynq SoC’s normal operation will trigger the interrupt.

 

I have attached the code to this blog post. It is split into three functions:

 

1. The first part configures the generic interrupt controller on the Zynq SoC so that we can use the XADC interrupt as part of this the interrupt service routine. It is called when the XADC interrupt is issued.

 

2. The second part configures the XADC, sets the sequencer to a safe mode, and disables all alarms before reading the temperature. It then assigns an upper and lower temperature alarm based upon the value it has just read. Having set these values the function then sets the temperature alarm and enables the temperature interrupt.

 

3. The third part is the interrupt service routine that will be called when the temperature interrupt occurs.  This routine will clear the interrupt status register, disable more interrupts from occurring, and read the temperature at which the interrupt occurred. The temperature reading might not be above the interrupt temperature as it will fluctuate and we do not have the temperature averaging turned on. However, the value should be close.

 

 

When I built the example code and generated the boot image, I observed the results below on the MicroZed board after it had been running for a few minutes:

 

 

 Image 5.png

 

 

As you can see the interrupt was triggered.  The number “513” (in decimal) following the status update is the value in the XADC interrupt status register.

 

The XADC can be a very powerful tool in both the system and FPGA designer’s tools box. This simple example shows how we can use it for prognostics. In a more critical application, we can also use it as part of an anti-tamper policy.

 

 

 

Please see the previous entries in this MicroZed series by Adam Taylor:

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 42: MicroZed Operating Systems Part 4

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 41: MicroZed Operating Systems Part 3

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 40: MicroZed Operating Systems Part Two

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 39: MicroZed Operating Systems Part One

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 38 – Answering a question on Interrupts

 

Adam Taylor’s MicroZed Chronicles Part 37: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 8

 

Adam Taylor’s MicroZed Chronicles Part 36: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 7

 

Adam Taylor’s MicroZed Chronicles Part 35: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 6

 

Adam Taylor’s MicroZed Chronicles Part 34: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 5

 

Adam Taylor’s MicroZed Chronicles Part 33: Driving Adafruit RGB NeoPixel LED arrays with the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 32: Driving Adafruit RGB NeoPixel LED arrays

 

Adam Taylor’s MicroZed Chronicles Part 31: Systems of Modules, Driving RGB NeoPixel LED arrays

 

 Adam Taylor’s MicroZed Chronicles Part 30: The MicroZed I/O Carrier Card

 

Zynq DMA Part Two – Adam Taylor’s MicroZed Chronicles Part 29

 

The Zynq PS/PL, Part Eight: Zynq DMA – Adam Taylor’s MicroZed Chronicles Part 28  

 

The Zynq PS/PL, Part Seven: Adam Taylor’s MicroZed Chronicles Part 27

 

The Zynq PS/PL, Part Six: Adam Taylor’s MicroZed Chronicles Part 26

 

The Zynq PS/PL, Part Five: Adam Taylor’s MicroZed Chronicles Part 25

 

The Zynq PS/PL, Part Four: Adam Taylor’s MicroZed Chronicles Part 24

 

The Zynq PS/PL, Part Three: Adam Taylor’s MicroZed Chronicles Part 23

 

The Zynq PS/PL, Part Two: Adam Taylor’s MicroZed Chronicles Part 22

 

The Zynq PS/PL, Part One: Adam Taylor’s MicroZed Chronicles Part 21

 

Introduction to the Zynq Triple Timer Counter Part Four: Adam Taylor’s MicroZed Chronicles Part 20

 

Introduction to the Zynq Triple Timer Counter Part Three: Adam Taylor’s MicroZed Chronicles Part 19

 

Introduction to the Zynq Triple Timer Counter Part Two: Adam Taylor’s MicroZed Chronicles Part 18

 

Introduction to the Zynq Triple Timer Counter Part One: Adam Taylor’s MicroZed Chronicles Part 17

 

The Zynq SoC’s Private Watchdog: Adam Taylor’s MicroZed Chronicles Part 16

 

Implementing the Zynq SoC’s Private Timer: Adam Taylor’s MicroZed Chronicles Part 15

 

MicroZed Timers, Clocks and Watchdogs: Adam Taylor’s MicroZed Chronicles Part 14

 

More About MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 13

 

MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 12

 

Using the MicroZed Button for Input: Adam Taylor’s MicroZed Chronicles Part 11

 

Driving the Zynq SoC's GPIO: Adam Taylor’s MicroZed Chronicles Part 10

 

Meet the Zynq MIO: Adam Taylor’s MicroZed Chronicles Part 9

 

MicroZed XADC Software: Adam Taylor’s MicroZed Chronicles Part 8

 

Getting the XADC Running on the MicroZed: Adam Taylor’s MicroZed Chronicles Part 7

 

A Boot Loader for MicroZed. Adam Taylor’s MicroZed Chronicles, Part 6 

 

Figuring out the MicroZed Boot Loader – Adam Taylor’s MicroZed Chronicles, Part 5

 

Running your programs on the MicroZed – Adam Taylor’s MicroZed Chronicles, Part 4

 

Zynq and MicroZed say “Hello World”-- Adam Taylor’s MicroZed Chronicles, Part 3

 

Adam Taylor’s MicroZed Chronicles: Setting the SW Scene

 

Bringing up the Avnet MicroZed with Vivado

 

 

 

 

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.