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 (185,445 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

 

 

 

 

Comments
by Explorer
‎07-29-2014 03:37 PM - edited ‎07-29-2014 03:48 PM

hi Adam,

 

thank you again for this helpufull part, really i apraciate for this nice work, just i will test it on my zedboard, but with a little  modification, witch is an add, reading the alarm on Led or Oled

 

can you please, post the code of the example

 

thank you, and still blog In  Smiley Wink

 

 

by Explorer
on ‎07-29-2014 04:54 PM

hi Adam

 

i make the same design on 2014.1, but still getting the same alert, ( just before go to SDK ), the vp/vn pin of XADC, must be connect, and under bloc spcification, there is no option to desactavate those pin ? so i make an externet port 

 

 

 

Screenshot3.jpg

by Observer taylo_ap
on ‎07-30-2014 08:50 AM

GMA 

 

What you are showing is a critical warning you can still export to SDK and write the SW. One of the functions of a engineer is to check warnings in realtion to his system concept and design and either allow them to progress like you can in this instance or if you need to go back and take action (as you would if something you wanted got optimised out in the extreme case)

 

Adam 

by Explorer
on ‎07-31-2014 01:41 AM

hi Adam

 

yes, just if i choose " Generate bloc design ", this message appear, as it show in the screenshot below

Screenshot_6.jpg

 

but as you mentionned, you are right, we can export without connect this pin Smiley Happy

i tried to work on vivado 2014.2, for the same project, but i meet problem with export to SDK, in this version, there is some change, please check my last post on this topic, many people ( like me ), meet this problem, and i decide to retun to work on vivado 2013.4, because it's more  stabel then vivado 2014.1 ( some tme, it's close withou any reason, it's during the export step )

 

byt he way, when i export the design to SDK ( on 2014.3 or 2014.1 ), i still can't read temperature of voltage, as i mentionned in my previous post, i tried again, to read the statut of XADC bloc design, but it seem, not conected, or maybe i must wait for more time, but i think the problem is in design, i think Zedboard is different with microzed, also i doubt in axi interconnect bloc, and his connection, ( it's manualy )

 

any way, i will try another solution, and i will make a feedback if i succeed 

 

thank you Adam for your help, and please don"t stop this fantastic blog Smiley Happy

by Explorer
on ‎08-02-2014 09:54 AM

hi Adam,

 

finaly , it's work 

 

Screenshot_7.jpg

 

thank you Adam, and again, don't stop this nice blog  Smiley Wink

 

keep going as marines  said Smiley Wink

by Explorer
on ‎08-08-2014 02:01 AM

hi

 

please, can you submit the code source 

 

thank you

by Observer taylo_ap
on ‎08-18-2014 11:40 AM

Hi GMA 

 

I have sent thhe code to Steve to attach

 

Adam 

by Newbie e_an
on ‎02-11-2016 02:29 AM

Hello,

 

I'm new to programming and my English is not good.

 

I try to read the statut of XADC in my Zedboard but only give me problems. I think the problem is in the design, in axi interconnect bloc. I had not use this bloc before.

 

Can someone help me?

 

Thanks

by Xilinx Employee
on ‎02-11-2016 11:52 AM

e_an: Your question is so general that I recommend you start with one of the technical support forums on the Xilinx site. This blog is not set up to support new users needing broad help.

 

--Steve

 

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.