cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
berker_atel
Adventurer
Adventurer
2,576 Views
Registered: ‎11-09-2016

Zynq interrupt problem

Jump to solution

Hi,

 

I use simple interrupt code for long time,but now it doesn't works! I can't see any problem,anyone see the problem?

thanks

Berker

 

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

XScuGic 	     Intc_ins;
XScuGic_Config   Intc_cfg;
XGpio            Gpio0_ins;
XGpio_Config     Gpio0_cfg;

#define GPIO0_BASE       0x41200000
#define GPIO0_IRQID  	 61


static volatile u32 Gpio0_Flag;
static volatile u32 BUTTONS;

void GPIO0_ISR(void *CallbackRef);


int main()
{
    init_platform();

    print("Hello World\n\r");
    Gpio0_Flag = 0;

    XGpio         *Gpio0_ins_p = &Gpio0_ins;
    XGpio_Config  *Gpio0_cfg_p = &Gpio0_cfg;
    Gpio0_cfg_p =  XGpio_LookupConfig(0);
	XGpio_CfgInitialize(Gpio0_ins_p, Gpio0_cfg_p,Gpio0_cfg_p->BaseAddress);


    XScuGic          *Intc_ins_p = &Intc_ins;
    XScuGic_Config   *Intc_cfg_p = &Intc_cfg;
    Intc_cfg_p = XScuGic_LookupConfig(0);
	XScuGic_CfgInitialize(Intc_ins_p, Intc_cfg_p,Intc_cfg_p->CpuBaseAddress);
	XScuGic_SetPriorityTriggerType(Intc_ins_p, 61,0x00, 0x3);
	//XScuGic_SetPriorityTriggerType(&INTC_ins, ID1,0xA0, 0x3);
	Xil_ExceptionInit();
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
				(Xil_ExceptionHandler)XScuGic_InterruptHandler,
				Intc_ins_p);
	XScuGic_Connect(Intc_ins_p,GPIO0_IRQID,
				 (Xil_ExceptionHandler)GPIO0_ISR,
				 (void *)Gpio0_ins_p);
	XScuGic_Enable(Intc_ins_p,GPIO0_IRQID);
	Xil_ExceptionEnable();

    while(1)
    {

	   if (Gpio0_Flag == 1)
		{
		   Gpio0_Flag = 0;
		   print("IRQ\n\r");

		}

	   Xil_Out32(0x41200008,Xil_In32(GPIO0_BASE));
    }


    cleanup_platform();
    return 0;
}

void GPIO0_ISR(void *CallbackRef)
{
	//XGpio *GpioPtr = (XGpio *)CallbackRef;
	Gpio0_Flag = 1;
	BUTTONS = Xil_In32(GPIO0_BASE); //Read GPIO
	Xil_Out32(GPIO0_BASE+0x0120,0x00000001); //Toggle IRQ Status
}



0 Kudos
1 Solution

Accepted Solutions
berker_atel
Adventurer
Adventurer
4,235 Views
Registered: ‎11-09-2016

I forgot to 2 lines to enable interrupts.

Now,it it fixed

 

    Xil_Out32(GPIO0_BASE+0x011C,0x80000000); //Global IE
    Xil_Out32(GPIO0_BASE+0x0128,0x00000001); //IE

 

View solution in original post

0 Kudos
1 Reply
berker_atel
Adventurer
Adventurer
4,236 Views
Registered: ‎11-09-2016

I forgot to 2 lines to enable interrupts.

Now,it it fixed

 

    Xil_Out32(GPIO0_BASE+0x011C,0x80000000); //Global IE
    Xil_Out32(GPIO0_BASE+0x0128,0x00000001); //IE

 

View solution in original post

0 Kudos