dougr
April 6, 2023, 7:21pm
1
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!
dougr
April 7, 2023, 12:06pm
2
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?
rtel
(Richard Barry)
April 7, 2023, 2:16pm
3
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?
dougr
April 7, 2023, 3:25pm
4
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?
rtel
(Richard Barry)
April 10, 2023, 3:09pm
5
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.
dougr
April 11, 2023, 11:20am
6
I have it working. I need to add: Xil_ExceptionEnable();
aggarg
(Gaurav Aggarwal)
April 11, 2023, 11:26am
7
Thank you for reporting back.