UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
3,521 Views
Registered: ‎12-27-2010

External Hardware Interrupt

I am trying to interface SPI based sensor with ML403 board.Can any one tell me how can i write few lines of C code so that i  treat external SPI device interrupt as a hardware interrupt to the xps_intc_IP, so that it will give me correct interrupt catching all the time. Then try to put   polling based code at the xps_intc_IP interrupt.

I will be gratefull .

 

0 Kudos
3 Replies
Xilinx Employee
Xilinx Employee
3,510 Views
Registered: ‎02-01-2008

Re: External Hardware Interrupt

Do you have something like the following to assign the pin as an interrupt source (at the top of your mhs file)

 

PORT external_irq_pin = external_irq_pin, DIR = I, SIGIS=INTERRUPT, SENSITIVITY=EDGE_RISING

 

Check UG642 (Platform Specification Format Reference Manual) for the sensitivity options.

0 Kudos
Contributor
Contributor
3,500 Views
Registered: ‎12-27-2010

Re: External Hardware Interrupt

Thanks for the reply johnmcd

johnmcd there is nothing like this in my mhs file.

john i want to get the interrupt siganl from the sensor and then collect the data .but the code i wrote is not working.

void SpiInterruptHandler(void *InstancePtr)
        {
        int status;
        u8 *BufferPtr;
        Xuint8 *SendBufPrt;
        Xuint8 *ReadBufPrt;
        int DelayCount = 0;
       
        //SS high
        XSpi_SetSlaveSelect(&Spi, 0x01);
   
       
        *SendBufPrt = 0x0A;
        *(SendBufPrt + 1) = 0x00;
       
        XSpi_Transfer(&Spi, SendBufPrt, NULL, 2);
        XSpi_Transfer(&Spi, SendBufPrt, ReadBufPrt, 2);
       
       
        //XSpi_Transfer(&Spi, ReadBufPrt, ReadBufPrt, 2);
        //XSpi_Stop(&Spi);

       
        //xil_printf("write byte %d (0x%X)\r\n",*sbuffer,*(sbuffer+1));
        xil_printf(" Read byte %x,%x\r\n",*ReadBufPrt,*(ReadBufPrt+1));
       
        //Pull the SS low
        XSpi_SetSlaveSelect(&Spi, 0x00);
       
   
}

 

 

then i came to know this

"you are enabling the interupt for the SPI interface but this should be done in
polling mode because the SPI device has no interupt connection.So it could be that the Spi interface is not working properly due to let say mis communication with respect to interrupt ".

but i dont know how to use  external SPI device interrupt as a hardware interrupt to the xps_intc_IP, so that it will give me correct interrupt catching all the time. Then use  polling based code at the xps_intc_IP interrupt.

 

Kindly help how to resolve this .

0 Kudos
Xilinx Employee
Xilinx Employee
3,428 Views
Registered: ‎02-01-2008

Re: External Hardware Interrupt

Maybe I missunderstood.

 

Are you trying to take an interrupt signal from an external device and connect it to the xps_intc controller?

 

If so, you need a special assignment added to that external interrupt signal input to the mhs. This assignment is required since the source of an interrupt (to the xps_intc controller) defines whether to use edge sensitive or level sensitive logic in the xps_intc controller.

 

So say your external interrupt signal is named external_irq_pin, you probably have it connected to the FPGA and assigned in your MHS like the following:

 

PORT external_irq_pin = external_irq_pin, DIR = I

 

In order to add the special assignements, you have to add SIGIS and SENSITIVITY to the port assignement so that it looks like the following (if the external interrupt is edge sensitive and goes low when active:

 

PORT external_irq_pin = external_irq_pin, DIR = I, SIGIS=INTERRUPT, SENSITIVITY=EDGE_FALLING

 

Next you would connect 'external_irq_pin' to the xps_intc controller and xps now knows to enable falling edge detection logic in the xps_intc controller for that signal.

 

BEGIN xps_intc
 PARAMETER INSTANCE = xps_intc_0
 PARAMETER HW_VER = 2.01.a
 PARAMETER C_BASEADDR = 0x81800000
 PARAMETER C_HIGHADDR = 0x8180ffff
 BUS_INTERFACE SPLB = mb_plb
 PORT Intr = RS232_Uart_1_Interrupt & SPI_IIC2INTC_Irpt & external_irq_pin
 PORT Irq = microblaze_0_Interrupt
END

 

Now, after you generate your software libraries, the xparameters.h file should include:

XPAR_SYSTEM_EXTERNAL_IRQ_PIN_MASK

XPAR_XPS_INTC_0_SYSTEM_EXTERNAL_IRQ_PIN_INTR

 

You would use these defines to initialize and enable your interrupt handler.

 

0 Kudos