Jump to content
  • 0

read EOC bare-metal


HelplessGuy

Question

Hello everyone,

I am using a Zybo Z7-20 and want to read external, analog voltages. Now I read in the XADC documentation something about an EOC interrupt. And I want to use this interrupt in my bare-metal program to trigger the reading of the digitalized voltages.

But I don't find documentations, if there is an function existing for reading it out.

Can someone give me an advice or knows more about this than me?

Greetings from a really HelplessGuy

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

Hi @HelplessGuy,

I would look at the XADC Wizard v3.3 LogiCORE IP Product Guide and the 7 Series FPGAs and Zynq-7000 SoC XADC Dual 12-Bit 1 MSPS Analog-to-Digital Converter User Guide for information on the EOC interrupt. Here is a tutorial using zynq and the xadc. Here is a lab for using the zedboard(zynq) with xadc. Here is a good reference for using the zynq processor.

thank you,

Jon

 

 

Link to comment
Share on other sites

Hi @jpeyron

thanks for your answer. both examples are looking very good. The problem is only, that the interrupt isn't working.

Do I have to add the connection in the block diagram from eos_out to the zynq-block or from iip2intc_irpt?

I also add my code at the bottom, maybe you can find my mistake! If it is correctly working at the end, I also will give you my project for other users. Because I think this is a very useful example at the end.

#include <stdio.h>
#include "platform.h"

#include "xparameters.h"
//#include "xgpio.h"
#include "xadcps.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xil_printf.h"

// Parameter definitions
#define INTC_DEVICE_ID            XPAR_PS7_SCUGIC_0_DEVICE_ID
#define XADC_DEVICE_ID            XPAR_PS7_XADC_0_DEVICE_ID
#define INTC_XADC_INTERRUPT_ID    XPAR_FABRIC_XADC_WIZ_0_IP2INTC_IRPT_INTR

u32 XAdc_INT = 0x000000030;     //Bit Mask of enabled interrupts of XADC
                                //EOS and EOC enabled
u32 test;

XAdcPs  XAdcInst;
XScuGic INTCInst;
static int value;

//-----------------------------------------------------------------
// PROTOTYPE FUNCTIONS
//-----------------------------------------------------------------
static void XADC_Intr_Handler(void *baseaddr_p);
static int  InterruptSystemSetup(XScuGic *XScuGicInstancePtr);
static int  IntcInitFunction(u16 DeviceId, XAdcPs *XAdcInstancePtr);

//-----------------------------------------------------------------
// INTERRUPT HANDLER FUNCTIONS
// - called by the XADC interrupt
// - toggles the value
//-----------------------------------------------------------------
void XADC_Intr_Handler(void *InstancePtr)
{
    // Disable XADC interrupts
    XAdcPs_IntrDisable(&XAdcInst, XAdc_INT);

    if ((XAdcPs_IntrGetStatus(&XAdcInst) & XAdc_INT) != XAdc_INT)
    {
        return;
    }
    // Increment counter based on button value
    // Reset if center button pressed
    if(value != 1)
    {
        value = value + 1;
    }
    else
    {
        value = 0;
    }
    printf("value is %i\n", value);

    (void)XAdcPs_IntrClear(&XAdcInst, XAdc_INT);
    // Enable XADC interrupts
    XAdcPs_IntrEnable(&XAdcInst, XAdc_INT);
}

//-----------------------------------------------------------------
// INITIAL SETUP FUNCTIONS
//-----------------------------------------------------------------
int InterruptSystemSetup(XScuGic *XScuGicInstancePtr)
{
    // Enable interrupt
    XAdcPs_IntrEnable(&XAdcInst, XAdc_INT);

    Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
                     (Xil_ExceptionHandler)XScuGic_InterruptHandler,
                     XScuGicInstancePtr);
    Xil_ExceptionEnable();

    return XST_SUCCESS;
}

int IntcInitFunction(u16 DeviceId, XAdcPs *XAdcInstancePtr)
{
    XScuGic_Config *IntcConfig;
    int status;

    // Interrupt controller initialization
    IntcConfig = XScuGic_LookupConfig(DeviceId);
    status = XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress);
    if (status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    // Call to interrupt setup
    status = InterruptSystemSetup(&INTCInst);
    if (status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    // Connect XADC interrupt to handler
    status = XScuGic_Connect(&INTCInst,
                 INTC_XADC_INTERRUPT_ID,
                 (Xil_ExceptionHandler)XADC_Intr_Handler,
                 (void *)XAdcInstancePtr);
    if (status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    // Enable XADC interrupts
    XAdcPs_IntrEnable(XAdcInstancePtr, XAdc_INT);

    // Enable XADC and timer interrupts in the controller
    XScuGic_Enable(&INTCInst, INTC_XADC_INTERRUPT_ID);

    return XST_SUCCESS;
}

int main()
{
    init_platform();
    int status;
    XAdcPs_Config *XADC_Config;

    //---------------------------------------------------------
    // INITIALIZE THE PERIPHERALS & SET DIRECTION OF GPIO
    //---------------------------------------------------------
    // Initialize Push Buttons
    XADC_Config = XAdcPs_LookupConfig(XPAR_PS7_XADC_0_DEVICE_ID);
    status = XAdcPs_CfgInitialize(&XAdcInst, XADC_Config, XADC_Config->BaseAddress);
    if (status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    XAdcPs_SelfTest(&XAdcInst);

    test = XAdcPs_IntrGetStatus(&XAdcInst);

    // Initialize interrupt controller
    status = IntcInitFunction(INTC_DEVICE_ID, &XAdcInst);
    if (status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    printf("%u\n", test);

    while(1)
    {
        ;
    }

    return 0;
}

 

Link to comment
Share on other sites

Hi @jpeyron

Thanks for your answer. The tutorial and the paper was really interesting. But has not really something to do with my problem.

Maybe I do not explain my problem(s) close enough:

1. If I want to let the XADC (event handled sampling) run interrupt handled. Do I have to connect the EOS/EOC signal to the Zynq-Block or to CONVST_in or both?

2. I connected to CONVST_in a signal that always goes to 1 and 0 but there was no conversation happening. Do you have an example for let the event-handled XADC run, I find for event handled nothing to compair with my problems?

Link to comment
Share on other sites

Hi @jpeyron

The screen shot helped a lot. But is not going on. The problem is, that the interrupt is never running. Or better saying, I think that the XADC is not starting converting. Somehow as a first trigger is missing. Is there something existing to give convst_in a first trigger pulse to start running, before EOC is doing the rest?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...