Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Visitor
mehta.vishal.360
Posts: 14
Registered: ‎08-03-2011
0

Information Regarding How to use Interrupts in Virtex2pro(for powerpc)

hello,

I am using virtex2pro board. I want to configure DIP switches as interrupt source so i selected interrupt option in BSB under Dip switches. Now i need to write the C code for using the interrupt Since more than one peripheral is used as in the number therefore Interrupt Controller is being used. I have written the following code after going thorugh the pdf related to interrupts

 

#include "xparameters.h"
#include "xgpio.h"
#include "stdio.h"
#include "xstatus.h"
#include "xuartlite_l.h"
#include "xgpio_l.h"
#include "xintc_l.h"
#include "xintc.h"


#define XPAR_LEDS_4BIT_DEVICE_ID 0
#define XPAR_DIPSWS_4BIT_DEVICE_ID 1

XGpio GpioOutput_Led;
XIntc InterruptController;

 void delay()
 {
  int i,j;
  for(i=0;i<200;i++)
     {
         for(j=i;j<100;j++)
             {
                 }
      }
    }
   
void gpio_int_handler(void *baseAddr_p)
{
 XGpio_mSetDataReg(XPAR_LEDS_

4BIT_BASEADDR, 1, 0x0000000f);
 xil_printf("interrupt working");
 }
 
int main()
{
  /* Initialize exception handling */
  XExc_Init();
  /* connect the GPIO interrupt */
  XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR,XPAR_XPS_INTC_0_DIPSWS_4BIT_IP2INTC_IRPT_INTR,(XInterruptHandler)gpio_int_handler,(void *)XPAR_DIPSWS_4BIT_BASEADDR);
  /* Start the interrupt controller */
  XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR);
  /* Enable dipswitch interrupts in the interrupt controller */
  XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, XPAR_DIPSWS_4BIT_IP2INTC_IRPT_MASK);
  /* Enable PPC non-critical interrupts */
  XGpio_Initialize(&GpioOutput_Led,XPAR_LEDS_4BIT_DEVICE_ID);
  XGpio_SetDataDirection(&GpioOutput_Led,1, 0x00);
  XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, 0x00000000);
  delay();
  while(1)
  {
   }
}
The only problem is that it is not going in to the ISR routine.Am i doing anything wrong in here??? My mhs file is like this

BEGIN ppc405
 PARAMETER INSTANCE = ppc405_0
 PARAMETER HW_VER = 3.00.a
 PARAMETER C_FASTEST_PLB_CLOCK = DPLB0
 BUS_INTERFACE DPLB0 = plb0
 BUS_INTERFACE IPLB0 = plb0
 BUS_INTERFACE JTAGPPC = jtagppc_cntlr_0_0
 BUS_INTERFACE RESETPPC = ppc_reset_bus
 PORT CPMC405CLOCK = sys_clk_s
 PORT EICC405EXTINPUTIRQ = EICC405EXTINPUTIRQ
END
BEGIN xps_intc
 PARAMETER INSTANCE = xps_intc_0
 PARAMETER HW_VER = 1.00.a
 PARAMETER C_BASEADDR = 0x81800000
 PARAMETER C_HIGHADDR = 0x8180ffff
 BUS_INTERFACE SPLB = plb0
 PORT Irq = EICC405EXTINPUTIRQ
 PORT Intr = DIPSWs_4Bit_IP2INTC_Irpt
END
Any help would be appreciated....
Super Contributor
stephenm
Posts: 127
Registered: ‎05-06-2012
0

Re: Information Regarding How to use Interrupts in Virtex2pro(for powerpc)

see attached pdf (a modified version of xapp778)