• 0

xadc example on ZYBO


Hi. Now i am using  z-7010 with  ZYBO.

I tried to convert  sine function (by function generator) to digital output.

I used Aux14 P/N port.

positive port was connected to sine signal and negative one was connected to ground.(like single-ended).


I got an array of raw data using XSysmon_GetAdcData(), and converted that array by using newly defined function. (below code) 


#define XSysMon_RawToExtVoltage(AdcData) ((((float)(AdcData))*(1.0f))/65536.0f)


Function generator output a 100-300mv, sine wave.

But when i used serial oscilloscope to see waveform of digitalized output,  amplitude of output signal was twice the input.


As you can se e, amplitude is 200-600mV.

i don't know why the output is twice the input.

Is there any problem in my code?


(I didn;t checked bipolar mode in xadc wizard.)

i used below code.

#include <stdio.h>
#include "platform.h"
#include "xsysmon.h"
static XSysMon SysMonInst; //sysmon instance

static int SysMonFractionToInt (float FloatNum); 
#define XSM_CH_AUX_7  23   //AUX7
#define XSM_CH_AUX_14 30   //AUX14
#define XSysMon_RawToExtVoltage(AdcData) ((((float)(AdcData))*(1.0f))/65536.0f) 

//#define XSysMon_RawToExtVoltage(AdcData) ((((float)(AdcData)))) 
int main( void )
	//u8 SeqMode;
	u32 TempRawData,VccIntRawData,Aux_7_raw,Aux_14_raw;
	float TempData,VccIntData,Aux_7,Aux_14;

	XSysMon_Config *SysMonConfigPtr;
	XSysMon *SysMonInstPtr = &SysMonInst;

	int xStatus;

	SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID);
	if (SysMonConfigPtr == NULL) printf("LookupConfig FAILURE\n\r");

	xStatus = XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr, SysMonConfigPtr->BaseAddress);
	if(xStatus != XST_SUCCESS) printf("CfgInitialize FAILED\r\n");


			while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK);//

			Aux_7_raw = XSysMon_GetAdcData(SysMonInstPtr,XSM_CH_AUX_7); 
			Aux_7 =XSysMon_RawToExtVoltage(Aux_7_raw);                

			Aux_14_raw = XSysMon_GetAdcData(SysMonInstPtr,XSM_CH_AUX_14); 
			Aux_14 =XSysMon_RawToExtVoltage(Aux_14_raw);                

			TempRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);//Read the on-chip Temperature Data
			TempData = XSysMon_RawToTemperature(TempRawData);

			VccIntRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT); //Read the on-chip Vccint Data
			VccIntData = XSysMon_RawToVoltage(VccIntRawData);

			//for serial oscilloscope 
					(int)(Aux_7), SysMonFractionToInt(Aux_7),
					(int)(Aux_14), SysMonFractionToInt(Aux_14),
					(int)(VccIntData), SysMonFractionToInt(VccIntData),
					(int)(TempData), SysMonFractionToInt(TempData));

	return 0;
/*The AUX14 channel is defined to be 30 in xsysmon.h :*/ //

#define XSM_CH_VCCPDRO 0x0F /**< On-chip PS VCCPDRO Channel, Zynq */
#define XSM_CH_AUX_MIN 16 /**< Channel number for 1st Aux Channel */
#define XSM_CH_AUX_MAX 31 /**< Channel number for Last Aux channel */
#define XSM_CH_VUSR0 32 /**< VUSER0 Supply - UltraScale */

int SysMonFractionToInt(float FloatNum)
	float Temp;
	Temp = FloatNum;
	if (FloatNum < 0) {
		Temp = -(FloatNum);
	return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));




Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now