02-16-2011 09:38 PM
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 .
02-17-2011 06:17 AM
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.
02-17-2011 10:44 AM
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 DelayCount = 0;
*SendBufPrt = 0x0A;
*(SendBufPrt + 1) = 0x00;
XSpi_Transfer(&Spi, SendBufPrt, NULL, 2);
XSpi_Transfer(&Spi, SendBufPrt, ReadBufPrt, 2);
//XSpi_Transfer(&Spi, ReadBufPrt, ReadBufPrt, 2);
//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
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 .
02-24-2011 09:57 PM
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.
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
Now, after you generate your software libraries, the xparameters.h file should include:
You would use these defines to initialize and enable your interrupt handler.