Getting interrupts to work on Zynq 7000 (ARM Cortext-A9) in Vitis

I’ve never used a RTOS before and I’m trying to get interrupts working on a Xilinx Zynq 7000 FPGA with an ARM Cortex-A9 PS in Vitis 2022.1.

I have a 1 HZ clock tied to interrupt 15 on the PS which should be ID 91.

Here’s the code I found and tried, but doesn’t work:

extern XScuGic xInterruptController;

Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
	(Xil_ExceptionHandler) XScuGic_InterruptHandler, &xInterruptController);

XScuGic_SetPriorityTriggerType(&xInterruptController, XPS_FPGA15_INT_ID, 4, 3);

XScuGic_Connect(&xInterruptController, XPS_FPGA15_INT_ID,
	(Xil_ExceptionHandler)ExtIrq_Handler, (void *)NULL);

XScuGic_Enable(&xInterruptController, XPS_FPGA15_INT_ID);

Could someone please help? Am I missing some code or using it wrong?

THANKS!

Still no luck.

I found some more example code which is slightly different than my first post, but still doesn’t work:

extern XScuGic xInterruptController;  // defined in portZynq7000.c
static XScuGic_Config *GicConfig;

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


int interrupt_init()
{
	int Status;

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

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

	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
			(Xil_ExceptionHandler) XScuGic_InterruptHandler, &xInterruptController);

	XScuGic_SetPriorityTriggerType(&xInterruptController, XPS_FPGA15_INT_ID, 4, 3);

	XScuGic_Connect(&xInterruptController, XPS_FPGA15_INT_ID,
			(Xil_ExceptionHandler)ExtIrq_Handler, (void *)NULL);

	XScuGic_Enable(&xInterruptController, XPS_FPGA15_INT_ID);

	return XST_SUCCESS;
}

XPAR_SCUGIC_0_DEVICE_ID = 0
XIL_EXCEPTION_ID_INT = 5
XPS_FPGA15_INT_ID = 91

Can anyone help?

Does the interrupt work in a bare metal application - without FreeRTOS or any other OS? If so, are you configuring the interrupt after starting the scheduler, so after the scheduler configures the interrupt controller?

I’ve been unsuccessful in getting this to work in bare metal code as well.

The interrupt to the PS is connected to a 1 Hz clock, so there is nothing to configure. Am I correct?

I don’t know the specifics of the clock or peripheral - but recommend getting the interrupt working in bare metal first, then FreeRTOS second. It only becomes a FreeRTOS usage question for this forum if it works in the non-RTOS configuration, but not the RTOS configuration.

I have it working. I need to add: Xil_ExceptionEnable();

Thank you for reporting back.