There are numerous topics about the mysterious XADC, but none of them is working up to date.
My Set-up:
Windows 7
ZedBoard Rev D, running PetaLinux v2013.10
Vivado 2015.4 (with provided SDK)
I have tried http://zynqhowto.blogspot.kr/ , but the lab 3 differes in cpp source file, I dont have "xsysmon.h" (was there any change with previous versions of Vivado ?). Also the PL design requires Reset Block (the design provided in Lab 3 cannot be otherwise validated).
Is there a simple TUTORIAL / REFERENCE PROJECT that shows how XADC samples external signal ?
----------------------------------------------------------
What I have done so far
According to Lab 3 tutorial
1) Design block diagram using:
processing_system7_0
axi_interconnect_0
rst_processing_system7_0_100M
xadc_wiz_0
adding the ports according to Lab 3 (vn_in, vp_in, ...)
- enabling Timer 0 in Zynq, setting Xadc according to tutorial Lab 3, runnig connection automation
2) constraints
#set_property PACKAGE_PIN E16 [get_ports vauxn0]
set_property IOSTANDARD LVCMOS33 [get_ports vauxn0]
#set_property PACKAGE_PIN E16 [get_ports vauxp0]
set_property IOSTANDARD LVCMOS33 [get_ports vauxp0]
#set_property PACKAGE_PIN D17 [get_ports vauxn8]
set_property IOSTANDARD LVCMOS33 [get_ports vauxn8]
#set_property PACKAGE_PIN D16 [get_ports vauxp8]
set_property IOSTANDARD LVCMOS33 [get_ports vauxp8]
#set_property PACKAGE_PIN M12 [get_ports vn_in]
set_property IOSTANDARD LVCMOS33 [get_ports vn_in]
#set_property PACKAGE_PIN ML11 [get_ports vn_in]
set_property IOSTANDARD LVCMOS33 [get_ports vp_in]
3) SDK
a) using Lab 3 source code - missing "xsysmon.h"
b) importing XADC Example from documentation - and adding a loop with usleep()
#include <stdio.h>
#include <unistd.h>
#include "xparameters.h"
#include "xadcps.h"
#include "xstatus.h"
#include "stdio.h"
#define XADC_DEVICE_ID ttXPAR_XADCPS_0_DEVICE_ID
#define printf xil_printf /* Small foot-print printf function */
static int XAdcPolledPrintfExample(u16 XAdcDeviceId);
static int XAdcFractionToInt(float FloatNum);
static XAdcPs XAdcInst; /* XADC driver instance */
int main(void)
{
tint Status;
tint loop = 0;
t/*
t * Run the polled example, specify the Device ID that is
t * generated in xparameters.h.
t */
twhile(loop < 50){
ttStatus = XAdcPolledPrintfExample(XADC_DEVICE_ID);
ttif (Status != XST_SUCCESS) {
tttreturn XST_FAILURE;
tt}
ttloop++;
ttprintf("loop: %d", loop);
ttusleep(500000); //wait 500ms
t}
treturn XST_SUCCESS;
}
int XAdcPolledPrintfExample(u16 XAdcDeviceId)
{
tint Status;
tXAdcPs_Config *ConfigPtr;
tu32 TempRawData;
tu32 VccPintRawData;
tu32 VccPauxRawData;
tu32 VccPdroRawData;
tfloat TempData;
tfloat VccPintData;
tfloat VccPauxData;
tfloat MaxData;
tfloat MinData;
tXAdcPs *XAdcInstPtr = &XAdcInst;
tprintf("r
MEASUREMENT r
");
t/*
t * Initialize the XAdc driver.
t */
tConfigPtr = XAdcPs_LookupConfig(XAdcDeviceId);
tif (ConfigPtr == NULL) {
ttprintf("r
FAILURE 01 r
");
ttreturn XST_FAILURE;
t}
tXAdcPs_CfgInitialize(XAdcInstPtr, ConfigPtr,
ttttConfigPtr->BaseAddress);
t/*
t * Self Test the XADC/ADC device
t */
tStatus = XAdcPs_SelfTest(XAdcInstPtr);
tif (Status != XST_SUCCESS) {
ttprintf("r
FAILURE 02 r
");
ttreturn XST_FAILURE;
t}
tVccPintRawData = XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VPVN);
tVccPintData = XAdcPs_RawToVoltage(VccPintRawData);
tprintf("r
The Current VCCPINT is %0d.%03d Volts. r
",
ttt(int)(VccPintData), XAdcFractionToInt(VccPintData));
tVccPauxRawData = XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VCCPAUX);
tVccPauxData = XAdcPs_RawToVoltage(VccPauxRawData);
tprintf("r
The Current VCCPAUX is %0d.%03d Volts. r
",
ttt(int)(VccPauxData), XAdcFractionToInt(VccPauxData));
treturn XST_SUCCESS;
}
int XAdcFractionToInt(float FloatNum)
{
tfloat Temp;
tTemp = FloatNum;
tif (FloatNum < 0) {
ttTemp = -(FloatNum);
t}
treturn( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
}
Outcome
I cant read external pins, the displayed values are still the same, even though I have grounded the pins vp_in, vn_in, vaux0, vaoux8 on the XADC header