Hey,
I am trying to set up interrupt for GPIO PS, I followed a tutorial and could register and handle interrupts. However, the handler executes twice, once from bank 0 and the other from bank 1.
this is my code:
#include<stdio.h>
#include"platform.h"
#include"xgpiops.h"
#include"xil_exception.h"
#include"xscugic.h"
void GpioPsHandler(void *CallBackRef, int Bank, u32 Status)
{
tXGpioPs* pGpioPs = (XGpioPs*) CallBackRef;
tXGpioPs_IntrDisablePin(pGpioPs, 50);
txil_printf("GpioPs Handler runningu2026 Bank: %d | Status: %x r
", Bank,
tttStatus);
tXGpioPs_IntrEnablePin(pGpioPs, 50);
}
int main()
{
tinit_platform();
tXGpioPs GpioPs;
tXGpioPs_Config* pGpioPsCfg;
tpGpioPsCfg = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
tXGpioPs_CfgInitialize(&GpioPs, pGpioPsCfg, pGpioPsCfg->BaseAddr);
tXGpioPs_SetOutputEnablePin(&GpioPs, 50, 0x0);
tXGpioPs_SetIntrTypePin(&GpioPs, 50, XGPIOPS_IRQ_TYPE_EDGE_RISING);
tXGpioPs_SetCallbackHandler(&GpioPs, (void*) &GpioPs, GpioPsHandler);
tXGpioPs_IntrEnablePin(&GpioPs, 50);
tXScuGic ScuGic;
tXScuGic_Config* pScuGicCfg;
tpScuGicCfg = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID);
tXScuGic_CfgInitialize(&ScuGic, pScuGicCfg, pScuGicCfg->CpuBaseAddress);
tXScuGic_Disable(&ScuGic, 52);
tXScuGic_SetPriorityTriggerType(&ScuGic, 52, 0xa0, 0x01);
tXScuGic_Connect(&ScuGic, 52, (Xil_ExceptionHandler) XGpioPs_IntrHandler,
ttt(void*) &GpioPs);
tXScuGic_Enable(&ScuGic, 52);
tXil_ExceptionInit();
tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
ttt(Xil_ExceptionHandler) XScuGic_InterruptHandler, &ScuGic);
tXil_ExceptionEnable();
txil_printf("Gpio interrupt test, press BTN8 on zedboard.r
");
twhile (1)
t{}
treturn 0;
}
---------------------------------
and this is the result when I pres BTN8 once:
Gpio interrupt test, press BTN8 on zedboard.
GpioPs Handler runningu0085 Bank: 0 | Status: 0
GpioPs Handler runningu0085 Bank: 1 | Status: 40000
-----------------------------------------
Of course I can put "if (Bank != 1) return;", in the first line of the handler, but I would love to manage this properly.
Any thoughts where is this problem coming from ?