Hi there,
PROBLEM:
Temperature readings are FINE (slightly changing over time, around 40 degrees (maybe some calibration is needed)). The external readings are 0 !!!! (using VP_in, VN_in) WHY ? WHY ARE EXTERNAL READINGS 0.00 ?
Set-up:
Zedboard with voltage 0.44 V applied between VP and VN pins. (differential pins)
Hardware Description:
I am trying to work with XADC wizard on ZedBoard, following the well-known mhkang64 lab 3. Therefore I have simple design consisting only of Zynq PS, AXI interconnect and XADC wizard (System Reset is included automatically). Only 2 pins are included, the vp_in and vn_in (I have excluded all the AUX pins to keep it simple). The XADC is configures into Channel Sequencer mode / Continuous mode / with AXI4 Lite (everything according to lab 3).
Constraints:
set_property IOSTANDARD LVCMOS33 [get_ports {vn_in}]
set_property IOSTANDARD LVCMOS33 [get_ports {vp_in}]
Software:
I am using the example code for polling the XADC, it is a little bit adjusted (shortened) to read only CURRENT value of Temperature and External Input Pins. Just scroll down to the "//CUSTOMIZED PART" (a while loop), everything else is the same (copied from the example).
/***************************** Include Files ********************************/
#include "xparameters.h"
#include "xadcps.h"
#include "xstatus.h"
#include "stdio.h"
#include <stdlib.h>
/************************** Constant Definitions ****************************/
#define XADC_DEVICE_ID ttXPAR_XADCPS_0_DEVICE_ID
/***************** Macros (Inline Functions) Definitions ********************/
#define printf xil_printf /* Small foot-print printf function */
/************************** Function Prototypes *****************************/
static int XAdcPolledPrintfExample(u16 XAdcDeviceId);
static int XAdcFractionToInt(float FloatNum);
/************************** Variable Definitions ****************************/
static XAdcPs XAdcInst; /* XADC driver instance */
/****************************************************************************/
int main(void)
{
tint Status;
t/*
t * Run the polled example, specify the Device ID that is
t * generated in xparameters.h.
t */
tStatus = XAdcPolledPrintfExample(XADC_DEVICE_ID);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
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
Entering the XAdc Polled Example. r
");
t/*
t * Initialize the XAdc driver.
t */
tConfigPtr = XAdcPs_LookupConfig(XAdcDeviceId);
tif (ConfigPtr == NULL) {
ttreturn XST_FAILURE;
ttprintf("r
XAdcPs_LookupConfig() returns XST_FAILUREr
");
t}
tXAdcPs_CfgInitialize(XAdcInstPtr, ConfigPtr,
ttttConfigPtr->BaseAddress);
tStatus = XAdcPs_SelfTest(XAdcInstPtr);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
ttprintf("r
XAdcPs_SelfTest() returns XST_FAILUREr
");
t}
tXAdcPs_SetSequencerMode(XAdcInstPtr, XADCPS_SEQ_MODE_SAFE);
tint c = 0, d = 0;
// CUSTOMIZED PART
twhile(1){
tt// Temperature
ttTempRawData = XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_TEMP);
ttTempData = XAdcPs_RawToTemperature(TempRawData);
ttprintf("r
The Current Temperature is %0d.%03d Centigrades.r", (int)(TempData), XAdcFractionToInt(TempData));
tt// VP & VN
ttVccPintRawData = XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VPVN);
ttt// file: xadcps.h
ttt// #define XADCPS_CH_VPVNtt0x3 /**< VP/VN Dedicated analog inputs */
ttt// file: xadcps_v2_2/src/xadcps.h
ttt// #define XADCPS_CH_VPVNtt0x3 /**< VP/VN Dedicated analog inputs */
ttVccPintData = XAdcPs_RawToVoltage(VccPintRawData);
ttprintf("rThe Current VPVN is %0d.%03d Volts. r
", (int)(VccPintData), XAdcFractionToInt(VccPintData));
// WAIT
tt for ( c = 1 ; c <= 2000 ; c++ ){
tt for ( d = 1 ; d <= 32000 ; d++ ){}
tt }
tt c = 0;
tt d = 0;
t}
tprintf("Exiting the XAdc Polled Example. r
");
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))));
}
P.S.
I get 0.00 readings from external inputs, what ever I do. I suppose there might be misunderstanding regarding the Constraint file. Even though I have checked the documentation, I am not entirely sure, why I dont need to specify the location, just the IOSTANDARD.