Jump to content
  • 0

PL to PS interrupts on Genesys ZU-3EG


Question

Posted (edited)

Hello,

I am trying to make work this example: http://www.globaltek.kr/zynq-interrupt-example-tutorial/?ckattempt=1

I generated ~1 Hz signal and routed it to pl_ps_irq[0:0]. Following this document https://docs.xilinx.com/r/en-US/ug1085-zynq-ultrascale-trm/Signal-Overview, the XPAR_FABRIC_EXT_IRQ_INTR variable should be set to 89 - is this correct? The problem is that the handler is never called. I can see the signal 1Hz is present on the output pin.

Perhaps XPAR_FABRIC_EXT_IRQ_INTR should be in xparameters.h file? For some reason, it's not there. But after I enabled interrupt for axi_gpio_buttons, the corresponding entry has appeared in xparameters.h:

#define XPAR_FABRIC_AXI_GPIO_BUTTONS_IP2INTC_IRPT_INTR 136U

 

I will appreciate if somebody gives an idea on what I am doing wrong.

Below is my design and the code.

image.thumb.png.d3aeab64e5582cd8a973ac18b12cc623.png

 

And here is the code

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xgpio.h"
#include "xil_types.h"
#include "xscugic.h"
#include "xparameters.h"
#include "xscugic_hw.h"


#define XPAR_FABRIC_EXT_IRQ_INTR 89U


XScuGic InterruptController;
static XScuGic_Config *GicConfig;

void ExtIrq_Handler(void *InstancePtr)
{
	xil_printf("ExtIrq_Handler\r\n");
}

int SetUpInterruptSystem(XScuGic *XScuGicInstancePtr)
{
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, XScuGicInstancePtr);
	Xil_ExceptionEnable();
	return XST_SUCCESS;
}

int interrupt_init()
{
	int Status;

	GicConfig = XScuGic_LookupConfig(XPAR_SCUGIC_0_DEVICE_ID);
	if (NULL == GicConfig) {
		return XST_FAILURE;
	}
	Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = SetUpInterruptSystem(&InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = XScuGic_Connect(&InterruptController, XPAR_FABRIC_EXT_IRQ_INTR, (Xil_ExceptionHandler)ExtIrq_Handler, (void *)NULL);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	XScuGic_Enable(&InterruptController, XPAR_FABRIC_EXT_IRQ_INTR);
	return XST_SUCCESS;
}

int main()
{
    init_platform();
    print("Hello World\n\r");
    interrupt_init();
    while(1);
    print("Successfully ran Hello World application");
    cleanup_platform();
    return 0;
}

 

Edited by Laerke

3 answers to this question

Recommended Posts

  • 0
Posted

Hello @Laerke,

I've recreated the demo on Genesys ZU-3EG, and it works.

The first mistake that I saw in your project was the value for the #define XPAR_FABRIC_EXT_IRQ_INTR. It is 121U not 89U. Please check  ug1085https://docs.xilinx.com/r/en-US/ug1085-zynq-ultrascale-trm/System-Interrupts?tocId=PD9FTob69sVTjQEM8sOQ~g  chapter 13, table 13-1. 121-128 for pl_ps_irq0 and 136-143 for pl_ps_irq1.

Code bellow:

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "xscugic.h"


XScuGic InterruptController;
static XScuGic_Config *GicConfig;

void ExtIrq_Handler(void *InstancePtr)
{
  xil_printf("ExtIrq_Handler\r\n");
}

int SetUpInterruptSystem(XScuGic *XScuGicInstancePtr)
{
  Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, XScuGicInstancePtr);
  Xil_ExceptionEnable();
  return XST_SUCCESS;
}


int interrupt_init()
{
  int Status;

  GicConfig = XScuGic_LookupConfig(XPAR_SCUGIC_0_DEVICE_ID);
  if (NULL == GicConfig) {
    return XST_FAILURE;
  }

  Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  Status = SetUpInterruptSystem(&InterruptController);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  Status = XScuGic_Connect(&InterruptController, XPAR_FABRIC_PL_PS_IRQ0_0_INTR, (Xil_ExceptionHandler)ExtIrq_Handler, (void *)NULL);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  XScuGic_Enable(&InterruptController, XPAR_FABRIC_PL_PS_IRQ0_0_INTR);

  return XST_SUCCESS;
}


int main()
{
    init_platform();
    interrupt_init();
    print("Hello World\n\r");
    print("Successfully ran Hello World application");
    cleanup_platform();
    return 0;
}

 

xdc

set_property -dict { PACKAGE_PIN AB14  IOSTANDARD LVCMOS33 } [get_ports { pl_ps_irq0_0 }]; #sw[3]

 

I will try to add the project to our GitHub repository.

Best Regards,

Bogdan Vanca

 

 

 

 

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
×
×
  • Create New...