Hiii,
I am trying to convert a sine wave into digital signal with XADC using Zynq-7010 (XC7Z010) board but i am not getting any output. I tried so many tutorials. Anyone please help me....
I used Axi-lite interface and vp and vn as input, i tried with aux 2 channel also. i gave 1 Vpp sine wave with 1kh frequency. i want to read it on the terminals. I used XADC in single channel mode. I can able to read the on chip temp and voltages but i am not getting how i can enable the external analog input. I used as the following code and design
#include <stdio.h>
#include "xsysmon.h"
#include "xparameters.h"
#include "xil_io.h"
#include "xil_types.h"
#include "platform.h"
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
#define XSysMon_RawToExtVoltage(AdcData) \
((((float)(AdcData))* (1.0f))/65536.0f)
#define XSM_CFR0_DU_MASK 0x0800 /**< Bipolar/Unipolar mode */
#define XSM_VPVN_OFFSET (XSM_IP_OFFSET + 0x20C)
/**< ADC out of VP/VN */
static XSysMon SysMonInst;
int SysMonFractionToInt(float FloatNum);
int main()
{
u16 ExtVolRawData;
float ExtVolData;
int xStatus;
XSysMon_Config *SysMonConfigPtr;
XSysMon *SysMonInstPtr = &SysMonInst;
//static int incr_size = 0x0;
//volatile static int VN_OFFSET_VALUE = 0x7fff; //- Offset value for XADC's VN
init_platform();
print("Hello World\n\r");
//----------------------------------------------------------------------- SysMon Initialize
SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID);
if(SysMonConfigPtr == NULL) printf("LookupConfig FAILURE\n\r");
xStatus = XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr,SysMonConfigPtr->BaseAddress);
if(XST_SUCCESS != xStatus) printf("CfgInitialize FAILED\r\n");
// Disable the channel sequencer. The documentation states that we should do this
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
//Enable the Channel Sequencer in continuous sequencer cycling mode.
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
// Wait till the End of Sequence occurs
XSysMon_GetStatus(SysMonInstPtr); /* Clear the old status */
//set the INPUT enables.
XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_VPVN);
//set the SINGLE CHAN enables.
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);
while(1)
{
ExtVolRawData = XSysMon_GetAdcData(SysMonInstPtr,XSM_CH_VPVN); //Read the external Vpn Data
ExtVolData = XSysMon_RawToExtVoltage(ExtVolRawData);
printf("The Current VpVn is %0d.%03d Volts. \r\n", (int)(ExtVolData), SysMonFractionToInt(ExtVolData));
usleep(500000); //wait 500ms
}
return 0;
}
//----------------------------------------------------------------------------------------------
int SysMonFractionToInt(float FloatNum)
{
float Temp;
Temp = FloatNum;
if (FloatNum < 0) {
Temp = -(FloatNum);
}
return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
}
I am getting output as
The Current VpVn is 0.001 Volts. with the sine input of 1Vpp at 1 KHZ