Jump to content
  • 0

Problem with Basys 3 XADC Ip Core


Vishnuk

Question

Hi,

I have used XADC IP Core on my Basys 3 board, I am unable to get updated value. i Keep getting 0V Can you please help me out with this. I have attacthed the block design and SDK Code.

Kind regards

R Vishnu Kumar

Code

#include <stdio.h>
#include "xparameters.h"
#include "xsysmon.h"

#include "xil_cache.h"
//#include "xsysmon.h"
#include "sysmon_header.h"

#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID //ID of xadc_wiz_0
        static XSysMon SysMonInst; //a sysmon instance
        //static int SysMonFractionToInt(float FloatNum);

        int main()
        {
        u32 TempRawData,VccIntRawData,ExtVolRawData;
        float TempData,VccIntData,ExtVolData;
        int xStatus;
        XSysMon_Config *SysMonConfigPtr;
        XSysMon *SysMonInstPtr = &SysMonInst;
        //init_platform();
        printf("Hello World\n\r");
        printf("Test1\n\r");
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ SysMon Initialize
        SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID);
        if(SysMonConfigPtr == NULL) printf("LookupConfig FAILURE\n\r");
        printf("Test2\n\r");

        xStatus =     XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr,
                SysMonConfigPtr->BaseAddress);
        if(XST_SUCCESS != xStatus) printf("CfgInitialize FAILED\n\r");
        printf("Test3\n\r");
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
        XSysMon_GetStatus(SysMonInstPtr); // Clear the old status
        XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);
        XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
         //XSysMon_StartAdcConversion(SysMonInstPtr);
        while(1)
        { //wait until EOS activated
        while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOC_MASK    ) != XSM_SR_EOC_MASK    );

        VccIntRawData = XSysMon_GetAdcData(SysMonInstPtr,XSM_CH_VPVN); //Read the on‐chip    Vccint Data
        VccIntData = XSysMon_RawToVoltage(VccIntRawData);        printf("The Current VCCINT is %0d Volts. \n\r",VccIntData);
        XSysMon_ResetAdc(SysMonInstPtr);
        usleep(5000000);XSysMon_GetStatus(SysMonInstPtr); // Clear the old status
        //XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);
        XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
        //XSysMon_StartAdcConversion(SysMonInstPtr);
        }
        return 0;
        }
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐

 

micrxadc.jpg

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

I think you need to set the channel for conversion.
See here

https://www.xilinx.com/support/documentation/user_guides/ug480_7Series_XADC.pdf

Table 3-4 and Table 3.7, register 0x40 bits 0 .. 4.

I'm not familiar with the wrapper functions, but they couldn't guess beforehand, which one of the 16 AUX channels you want to read. So it needs to be set.

Link to comment
Share on other sites

problem solved i used Vaux 15 instead of Vp VN channel. Thanks lot for the reply. I have a query though. i will be using xadc for reading a ccd image so inorder to read 1000 pixel whose analog signal will be around 1Mhz, what do i do jus use a for loop

i.e  for i=1 to 1000

data=getadc(channel);

end

 

is this the right method?

 

 

 

Link to comment
Share on other sites

Hi,

I'm happy to hear that it works.
But, note that there is no "Vp/Vn" channel. The ADC has 16 AUX inputs that can be multiplexed to one of the two ADC cores.

I think what you did now was to read the value from the results register that belongs to the channel that is being triggered.
My proposal was to switch the ADC to the AUX input that is physically connected. Once you use more than one channel, this can't be avoided.

A "for" loop should get some data, but then your code becomes very brittle, timing-wise. Any interrupt that distracts the CPU for a microsecond will cause you to skip a sample.

I suspect you will have a hard time with a concept, where software is timing-critical. The easier way would be IMHO to use event-triggered mode via the XADC's CONVST pin, and a hardware FIFO.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...