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!

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

by Xilinx Employee ‎11-25-2013 12:07 PM - edited ‎05-26-2015 04:33 PM (232,713 Views)

By Adam Taylor

 

When we last looked at the MicroZed we had just finished implementing the hardware and exporting it to the SDK. Once exported, you should be able to see the added XADC within the System.mss and System.xml files available under your board support package (BSP) and hardware definition respectively:

 

 

 

Figure 1 System.mss and System.xml.jpg

 

 

 

System.mss will show the XADC and the driver type, which appears as “generic” in this import. In fact, the SDK does come with drivers for the XADC, which are defined with xadcps.h and are available under the include files within the BSP. As we will be using other driver types unique to the Zynq, I also included xil_types.h to support the u32 type.

 

The xil_types.h header defines a number of macros you can use to configure, control, and read from the XADC. Amongst other things, this header file contains definitions for the XADC registers, sampling averaging options, channel sequence options, and power-down modes. It also contains a series of type definitions, macros, and other functions.

 

For my simple example, I am going to read the Zynq SoC’s internal temperature and voltage parameters and output them over an RS-232 link.

 

The first thing to do in the code is to look up the configuration of the XADC to be initialized; this requires a pointer of type "XAdcPs_Config." Using the function call "XAdcPs_LookupConfig()" coupled with the device ID this function will return 0 as there is only one XADC block within the Zynq. The configuration (device ID and base address of the XADC being initialized, see xparameters.h for this) will be stored in the pointer. If the configuration for the XADC with the device ID cannot be found, then "null" will be returned allowing the error to be handled.

 

The next step in the initialization process is to use the information previously obtained and stored within the configuration pointer, which requires a pointer of type "XAdcPs."

 

I named my configuration pointer "ConfigPtr" and my instantiation pointer "XADCInstPtr" (very original, as I'm sure you will agree).

 

Having initialized the XADC, the next few steps configure it for my example:

 

  1. Use the "XAdcPs_SelfTest()" function to perform a self-test to check that there are no issues with the device.
  2. Use "XAdcPs_SetSequencerMode()" to stop the sequencer from performing its current operation by setting it to a single channel.
  3. Use "XAdcPs_SetAlarmEnables()" to disable any alarms that may be set.
  4. Use "XAdcPs_SetSeqInputMode()" to restart the sequencer with the desired sequence.
  5. Use "XAdcPs_SetSeqChEnables()" to configure the enables for the channels I wish to sample.

 

Reading a sample from the XADC can be as simple as calling the function "XAdcPs_GetAdcData()." For the internal temperature and voltage parameters, I then used two of the provided macros -- "XAdcPs_RawToTemperature()" and "XAdcPs_RawToVoltage()" -- to convert the raw XADC values into their real-world temperature or voltage equivalents.

 

 

Figure 2 Reading an XADC Sample.jpg

 

 

Both these raw and real-world values are then output over an RS-232 link to be displayed in a terminal window. When I ran my code I was presented with the following results:

 

Figure 3 XADC Program Output.jpg

 

 

Below, you can download the attached C file I used to generate this output.

 

 

 

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

 

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 (Part 2)

 

Bringing up the Avnet MicroZed with Vivado (Part 1)

 

Comments
by Newbie bpwilliams
on ‎11-27-2013 12:04 PM

I really appreicate these tutorials for the MicroZed! Keep them coming!  Smiley Happy

by Visitor pmiller1
on ‎01-21-2014 10:54 AM

I see you've connected the XADC Wizard through AXI-lite, but then here you don't seem to address the device through AXI. Also in none of the XADC macros do I see a reference to the AXI base address. Is the main XADC communication done directly from the PS and not through AXI? If so, what is the AXI4-lite interface used for?

by Visitor pmiller1
on ‎01-21-2014 01:37 PM

I noticed you connected the XADC Wizard through AXI, but here you didn't mention anything about communicating with it through AXI. Do you even need AXI to get the XADC to work? And if not then what's the AXI port for?

by Xilinx Employee
on ‎01-21-2014 02:04 PM

Pmiller1: I regret that there's no support available from this blog. Please use the Xilinx technical support forums for your questions.

 

--Steve

 

by Observer taylo_ap
on ‎01-22-2014 12:35 AM

Pmiller1,

 

I will answer both of your questions in this one post I hope Smiley Wink

 

Communication between the PS and PL side of the Zynq is via the AXI interface either the GP or HP ports depending upon the task in hand. If you read part seven of this blog you will see in this a block diagram where I add in the XADC into the system using the vivado flow. In this diagram you can see a connection from the PS AXI GP port to the AXI interconnect and then to the XDC AXI lite port.

 

You can find the address range of the XADC and the rest of your system in the include file xparameters.h (under your BSP in SDK) you can of course also see these with the Vivado.

 

Regarding addressing over AXI the Zynq PS side uses the AXI bus (mostly there is some AHB and APB) as the processor bus connecting OCM, Cache, Memory Interfaces etc this means at a software level is it a simple as calling one of the generic read/write functions or using one of the functions very helpfully provided in thsi case the XADC functions. You might be interested in reading the first section of the Technical Reference Manual (http://www.xilinx.com/support/documentation/user_guides/ug585-Zynq-7000-TRM.pdf) Page 27 gives a very nice block diagram overview showing the PS side buses and interconnects.

 

If you have any other questions please feel free to ask

 

Adam

by Observer nitron
on ‎05-05-2014 05:47 AM

Hi Adam,

 

Thank You for this very interesting blog. Please keep on!

 

I am a little bit puzzled by the fact that you are using  xadpc driversalthough all the examples in the Zynq system.mss file are done with sysmon instead.

Is there any specific reason you choose xadpc ?

If my understanding Xilinx maintains two libraries/drivers for the same peripheral, the XADC... Bizarre !

 

Is there any difference between sysmon and xadpc in terms of functionnality you are aware of?

 

Is there any recommendation to use one or the other?

 

Best Regards and thanks again!

by Observer taylo_ap
on ‎05-05-2014 11:10 AM

Hi nitron,

 

Thank you for your kind comments.

 

I am not sure of what the offical line is on the Sysmon and XADCPS usage. 

 

However, when I worte the first zedboard blogs over on the now defunct All Programmable Planet, I used the planahead, edk flow and this called up the XADCPS files so I used those.

 

When I started this blog using the microzed and vivado, I noticed a few issued when the XADC was exported as a result it did not correctly update the XADC drivers in the system.mss. Having previously known about XADCPS I defualted to that solution. 

 

I would imagine both work in a similar manner and I found using XADCPS very simple to use, if you are using interrupts you might be interested in the blogs I wrote on using the Zynq interrupt controller.

 

Please drop me a line if I can help any more, best regards

 

Adam 

by Observer bbinb
on ‎07-09-2014 04:34 AM

Hi Adam,

 

Thanks for your excellent Tutorial on using MicroZed device. I benefited a lot from it.

 

I accomplished finishing tutorials up to PS-PL communicatin. I skipped XADC tutorial, actually tried but it didn't work. Then for PS-PL communication tutorial I noticed that I have problems on using PL side. I have never communicate to PL side. 

 

I did what you did in these tutorials, but anyhow I have such a problem.

 

In these tutorials and other user manuals, it is stated that when one wants to use PL side it is needed to enable voltage level shifters. However, I couldn't find how to do it, or do I need to make any change? Maybe that was the problem but I am not sure. My question is do I need to make any change in Xilinx SDK or any environment to enable level shifters? 

 

The error I get is when debugging the SW occurs in executing Xil_Out32() function:

 

Error while handling inferior event

Remote failure reply: E01

 

Thanks in advance,

by Visitor xil3s92f
on ‎07-09-2014 07:44 AM

@bbinb I had the same issues. In the SDK when you setup the debug configuration, you should make sure to enable the post ps7 init. That will take care of enabling the level shifters.

 

Raul

by Observer bbinb
on ‎07-09-2014 11:49 PM

@xil3s92f Thanks for the help. I couldn't find how to do it though. Do I need to change anything in "ps7_init.tcl" file or do another thing?

by Observer taylo_ap
on ‎07-11-2014 01:25 PM

@bbinb

 

Sorry about the delay in replying I have been traveling for work. 

 

There is an interesting section in the Zynq TRM which shows that the process for setting the level shifters to the enabled status section 2.4 in UG585 Zynq 7000 TRM. it gives power up and power down sequences. 

 

Please check that within PS7_init.c that there is line like

 

EMIT_MASKWRITE(0XF8000900, 0x0000000FU ,0x0000000FU),

 

Which enables the level shifters in the post configuration function 

by Observer bbinb
on ‎07-13-2014 11:01 PM

@taylo_ap

 

Thanks for help. Somehow the problem is solved. I modified ps7_init.tcl file and added ps7_post_config method (which includes EMIT_MASKWRITE(0XF8000900, 0x0000000FU ,0x0000000FU) instruction) into the ps7_init method in the file.

 

I was using JTAG to boot and haven't tried FSBL boot approach but I hope it will work also.

 

by Explorer
on ‎07-20-2014 10:43 AM

hello

 

this is an excellent tutorial, i still more then 1 month to found a thing like this, but i work on zedboard, i think it's similar, when working on this board and vvado, same as microzed and vivado, but what if i will use XPS to generate the sae solution for zedboard ?

and i have another question, when i added the XADC to my design, ( yes XADC is connected to AXI-lite, throught the  " automation connection " ), i can't found a documentation ( i cecked all PDF of XADc on ZYNQ ), talked about to what i must connect the Alarme pin ?

 

this is my post on zedboard forum : http://www.zedboard.org/content/xadc-output

and please, check my post on xilinx forum  : http://forums.xilinx.com/t5/Embedded-Development-Tools/XADC-output/m-p/490358#M32401

 

thank you again for this nice blog, and keep going Smiley Happy

thank you

by Observer taylo_ap
on ‎07-21-2014 11:45 AM

gma-87

 

thank you for the kind words if this blog helps you please spread the word about it Smiley Wink

 

The main difference between the microzed and the zedboard will be the configuration of the Zynq on the board as shown here http://forums.xilinx.com/t5/Xcell-Daily-Blog/Bringing-up-the-Avnet-MicroZed-with-Vivado/ba-p/362901

 

In the second figure you can see the selection of board types this will auto configure the zynq system for the board it is mounted on. (you can do this by hand if you want too)

 

As far as I understand it the alarm outputs can be connected to directly to LED's via a output (or other logic blocks) etc as the actual interrupt is dedicated and you use the interrupt status register to determine the reason for the alarm.

 

I will try and do a blog on this, this week as I think it is important and worth a diversion from the current OS track to demonstrate such an important question 

 

Adam 

by Explorer
on ‎07-23-2014 02:54 AM

hi Adam,

 

thank you for your response on my question

 

as i understand, i think Statu register will be a nice solution, so without use a direct connect from XADC output pin to led, i just make a code to read what happen in register, and then write some alert on led 

 

thank you again

by Explorer
on ‎07-25-2014 03:27 AM

@taylo_ap 

 

hi Adam,

 

i folow your tutorial, ( am working on zedboard ), no error during design or export to SDK, just i paste your code, into hello world.c , but when i tried to get the same result on Tera Term, nothing happen, as you said, just we call the function of " XAdcPs_GetAdcData " , but i can't found where " XAdPs_RawToVoltage " is defined ( in what .h file )

 

 

Screenshot_3.jpg

even, i delete the second instruction of convert, nothing apeared ?

 

Screenshot_4.jpg

 

thank you

 

 

 

 

 

 

 

 

 

 

by Observer taylo_ap
on ‎07-25-2014 12:17 PM

GMA

 

The function is defined with xadcps.h as included within the top of the file 

 

#include <stdio.h>

#include "platform.h"

#include "xadcps.h"

#include "xil_types.h"

#define XPAR_AXI_XADC_0_DEVICE_ID 0

 

Adam 

 

 

by Explorer
on ‎07-26-2014 04:27 AM

@taylo_ap 

 

hi Adamn, sorry, i make a mistake, any way, it's ok know, but nother hapen just your message 

Screenshot_1.jpg

 

thank you

by Explorer
on ‎07-26-2014 05:04 AM

hi Adam

 

i think the problem is with the XADC, it's not initilized, because when i put the voltage and temperature instruction, into the while loop, nothing is happen, 

 

 when i place your instruction ( reset state ), in this loop, just after the voltage and temperature instruction, nothing hapen, even the printf of your message, and internal exception apear, so i conclude that the reason is the XADC ?

 

other thing, durin the design on vivado, some pin, must be connect to get project on SDK, and by the wa, no error whe, i make this

 

Screenshot_2.jpg

 

thank you Adam 

by Explorer
on ‎07-27-2014 09:13 AM

@taylo_ap

 

hi Adam

 

thank you for your response, i make a mistake in the name of this function.

 

but i still have a problem with the XADC, i put the those function ( voltage and temperature ) into while loop, in order to print those data, as you made, but no response ? even i change the position of your message into this while loop, just after voltage and temperature function, but this time, no message apear ??? and exception message apear 

 

return to design, in the begin , i'am oblige to made some change, not like your design, i used Vivado 2013.4, before export to SDK, error apeared, ask me to connec some pin, then export is fine, even i found all library and driver of XADC in the project ?

i dounbde that XADC is not initilized ? am trying

 

please check my design  below 

thank you

Screenshot_2.jpg 

 

by Explorer
on ‎07-28-2014 01:37 AM

@taylo_ap


hi Adam,

 

 

sorry, i made a mistake when i call this function, but i still have problem, i tried to place those function call into the wile loop,in order to get the voltage and temperaure value, but no response, the watchdog, is working perfectelly, i can get value,

 

when i place you message after those function ( xadc get data , temerature and voltage), an exection appear, and your message, don't print ?

 

i return to my design, i checked it, i saw that the XADC is perfectelly connected, by the way, during the design step, and when i tried to export the design  to SDK, error message appear, indicate that i must connec some input pin or XADC boc and AXI interconnect ? so made like it's show on the picture below, and whe, i export it, all is confirmed without any problem, even when i open the projecton SFK, evry thing is ok, i got the XADC driver, and i placed your code, but as i montionned in the begin, no response from XADC, i doubut that XADC doen't inititilized ? bu am not sure ? am tried to get some other value or try the other function of XADCOPs, but no respnse ?

please can you help me

am working on :

  - vivado 2014.3

 - Zedboard Rev D


Screenshot_2.jpg
thank you

 

by Explorer
on ‎07-28-2014 01:55 AM

hi Adam,

 

 

sorry, i made a mistake when i call this function, but i still have problem, i tried to place those function call into the wile loop,in order to get the voltage and temperaure value, but no response, the watchdog, is working perfectelly, i can get value,

 

when i place you message after those function ( xadc get data , temerature and voltage), an exection appear, and your message, don't print ?

 

i return to my design, i checked it, i saw that the XADC is perfectelly connected, by the way, during the design step, and when i tried to export the design  to SDK, error message appear, indicate that i must connec some input pin or XADC boc and AXI interconnect ? so made like it's show on the picture below, and whe, i export it, all is confirmed without any problem, even when i open the projecton SFK, evry thing is ok, i got the XADC driver, and i placed your code, but as i montionned in the begin, no response from XADC, i doubut that XADC doen't inititilized ? bu am not sure ? am tried to get some other value or try the other function of XADCOPs, but no respnse ? 

 

link to my design screenshot : http://bit.ly/zedboard


please can you help me

 



am working on :

  - vivado 2014.3

 - Zedboard Rev D 

by Observer taylo_ap
on ‎07-28-2014 11:07 AM

GMA 

 

I am using 2014.1 and I do nt have to connect those pins, infact my blog this week has been inspired by your questions so I hoope it can help you find the answer to your issue. 

 

Once think you could try doing is checking for the succes of the XADC configuration asit returns XST success, if you are unsure how to do this check the code for my blog this week part 43 of this blog. 

 

Actually thinking about it how have you set the XADC up within Vivado particulalry the channel sequencer tab are vp/vn enabled to just read the internal parameters they do not need to be 

 

Capture2.PNG

 

by Explorer
on ‎07-29-2014 03:45 PM

@taylo_ap

 

hi

 

thank you for this response, i am sorry for the multiple post  of the same message, i got problem with read its on my browser, any way, thank you again for this explanation, i checked XADC bloc design, i founded that i didn't activate the channel sequencer, but i will remake the project on Vivado 2014.1

 

and about the part 43, i really apraciate for this helpfull tutorial 

 

keep going Smiley Wink

by Explorer
‎08-01-2014 11:21 AM - edited ‎08-02-2014 12:51 AM

hi Adam

 

 

during the disable of alarm  or stop sequencer mode

 

Use "XAdcPs_SetAlarmEnables()" to disable any alarms that may be set

 

Use "XAdcPs_SetSequencerMode()" to stop the sequencer from performing its current operation by setting it to a single channel.

 

when i tried to setup those instruction, i can't found the value of SequencerMode, whitch must choose, to ensure the stoping of the sequencer , of the folowing function , i checked the " name Configuration Register 1 (CFR1) mask(s) " in xadc_hw.h, but i can't indentify what i must set as a value in parameter function, when the calling step

 

void XAdcPs_SetSequencerMode(XAdcPs *InstancePtr, u8 SequencerMode)

 

so my question, if i want to disable or stop the sequencer or alarm , just i affect  0x0000 or another value, please check the foling choice 

 

XAdcPs_SetSequencerMode(&XADCMonInst, 0x0000);  

 

thank you 

 

 

by Newbie ericqiu
on ‎12-24-2015 09:50 PM

thanks

by Newbie smzk2001
on ‎08-08-2016 07:12 AM

Dear Adam, Thanks for your blog. I want to implement the same tutorial and I have generated the bit stream as mentioned in your blog. Now I am wrting the application side for this hardware. I have copied C the code but I have no definitions of the header files. i-e #include "xadcps.h" and #include "xil_types.h". Where can I get the codes for these files? please

by Observer taylo_ap
on ‎08-08-2016 01:58 PM

Hi smzk2001

 

You need to make sure you have generated the hardware with the XADC in it? have you then regenerated the BSP in SDK (just incase it did not pick up the hardware change) . 

You should be able to find the header files under the BSP -> ps7_cortexa9_0->libsrc->XADCPS_Vx_x

 

XIL types is a standard file so should be included under the BSP as well. 

 

Best

 

Adam 

by Visitor mmccolga
on ‎04-10-2017 10:23 AM

Hello,

 

The project exports to SDK with no errors for me. However when importing your .c file into my sources, I get the error that there is no file or directory for parameter.h.

 

I have located numerous platform.h fheader files on my device but there are all different. To which platform.h file is this one referring to and why is it not able to be loacted?

 

Thank You

by Observer taylo_ap
on ‎04-11-2017 02:42 PM

mmccolga

 

you will find the platform.h under you application as shown in the image below (note from a different project)

 

You need to create a BSP and Application project do not import my example into the hardware project within SDK when you first export the project. 

 

Please check out the first few blogs of this series if you are unsure of what I mean 

 

https://forums.xilinx.com/t5/Xcell-Daily-Blog/Adam-Taylor-s-MicroZed-Chronicles-Setting-the-SW-Scene/ba-p/364777

 

https://forums.xilinx.com/t5/Xcell-Daily-Blog/Zynq-and-MicroZed-say-Hello-World-Adam-Taylor-s-MicroZed/ba-p/367469

 

Thanks for reading 

 

Adam 

 

 

Capture.PNG

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.