- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Interrupt Handler not running, why?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-28-2009 09:10 AM - edited 05-28-2009 09:11 AM
Hello,
I have a custom core atatched to the microblaze PLB, which simply creates an interrupt with a given period. Its code is as generated by the periopheral wizard in EDK:
INTR_PROC : process( Bus2IP_Clk ) is
constant COUNT_SIZE : integer := 30;
constant ALL_ONES : std_logic_vector(0 to COUNT_SIZE-1) := (others => '1');
variable counter : std_logic_vector(0 to COUNT_SIZE-1);
begin
if ( Bus2IP_Clk'event and Bus2IP_Clk = '1' ) then
if ( Bus2IP_Reset = '1' ) then
counter := (others => '0');
intr_counter <= (others => '0');
else
counter := counter + 1;
if ( counter = ALL_ONES ) then
intr_counter <= (others => '1');
else
intr_counter <= (others => '0');
end if;
end if;
end if;
end process INTR_PROC;
IP2Bus_IntrEvent <= intr_counter;
This is a very simple core which I named cf_interface_2. I have checked all connections to the interrupt controller and they are OK:
BEGIN cf_interface_v2
PARAMETER INSTANCE = cf_interface_v2_0
PARAMETER HW_VER = 1.00.a
PARAMETER C_BASEADDR = 0xc6000000
PARAMETER C_HIGHADDR = 0xc600ffff
BUS_INTERFACE SPLB = mb_plb
PORT IP2INTC_Irpt = cf_interface_v2_0_IP2INTC_Irpt
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 = mb_plb
PORT Irq = Interrupt
PORT Intr = cf_interface_v2_0_IP2INTC_Irpt
END
I have written a simple C code to register the handler, start interrupt service, etc:
main()
{
xil_printf("\033[H\033[J"); //clears the screen
xil_printf("Hello!\n\r");
int loop_count, mem_data_read, mem_write_data[16], mem_test_size;
// The following function call initialize the GPIO ports. LEDS_4BIT is configured
// to be an output port
XGpio_mSetDataDirection(XPAR_LEDS_4BIT_BASEADDR, 1, 0x00000000);
XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, display_on);
//XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, display_on);
xil_printf("Waiting for interrupts...\n\r");
xil_printf("\n\r");
// Register the interrupt
XIntc_RegisterHandler(XPAR_INTC_0_BASEADDR, XPAR_XPS_INTC_0_CF_INTERFACE_V2_0_IP2INTC_IRPT_INT
// Start the interrupt controller
XIntc_mMasterEnable(XPAR_INTC_0_BASEADDR);
// Enable fe interrupts in the interrupt controller
XIntc_mEnableIntr(XPAR_INTC_0_BASEADDR, XPAR_CF_INTERFACE_V2_0_IP2INTC_IRPT_MASK);
// Enable microblaze interrupts
microblaze_enable_interrupts();
while(1);
}
void myhandler(void *baseAddr_p)
{
unsigned int csr;
int loop_count, dip_gpio_data, temp_data;
XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, 0x00);
xil_printf("Caught interrupt from FE Controller!\n\r");
// Clear the timer interrupt */
//XTmrCtr_mSetControlStatusReg(XPAR_FE_IN_CONTROLL
XIntc_Acknowledge(XPAR_INTC_0_BASEADDR,XPAR_XPS_IN
}
And the application stops at the second prinntf, and the interrupt handler never runs. Can someone please tell me what's wrong? I've checked everything and i'm running out of ideas..
Best,
JM
Solved! Go to Solution.
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-28-2009 10:12 AM
Hello,
I think you should refer to Embedded System Tools Reference Manual (est_rm.pdf) Appendix B which describes the Interrupt management. It also has a reference for an App Note (Xapp778.pdf) that you can find on the Xilinx website. It give a good overview of how the interrupts work and a couple of examples for different configurations. It also depends on how you configured your custom core if you used the wizard to create/import it.
Let us know if those references help.
FV
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-29-2009 01:42 AM
Hi,
I have runned the core driver test function, and it stops at the following instruction:
Reg32Value = CF_INTERFACE_V2_mReadReg(baseaddr, CF_INTERFACE_V2_INTR_DISR_OFFSET);
Why?
Best,
JM
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-29-2009 07:57 AM
I assume you used the create/import wizard which generated the sample device driver code. When you did this, there is an option of what type of interrupt structure you want to include for your device. I believe the default is to include the Device Interrupt Service Control (ISC) which you probably do not need (reference 'interrupt_control.pdf' for full description; search in your EDK installation directory). I have always not included this portion to simplify the hardware and necessary software since my simple IP Core is only generating 1 or 2 interrupts and this can be controlled by the IP ISC. If you selected NOT to include the Device ISC, then this might explain why the instruction stops. The register you are trying to read does not exist. If, on the other hand, you did include the Device ISC, I would step through this code in the debugger to make sure the address it is attempting to read is the address of your device.
The other thing, if you included the Device ISR, would be to make sure you are enabling the interrupts using the function in the device driver called 'name_of_your_device_EnableInterrupt()'. It is right above the interrupt handler in the function. It enables several registers in the IP ISC and the Device ISC, if you included it.
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-29-2009 08:06 AM
Thank you FV. I haven't included the ISC, but the driver should take this in account right?
Best,
JM
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-29-2009 09:28 AM
No, unfortunately, the driver is the same whether you include/exclude the Device ISC, which means that you need to take that piece of code out of the interrupt handler as well as the 'if' statement below it which is checking the return value against the interrupt mask.
I assume you mean you did not include the Device ISC.
FV
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-29-2009 09:40 AM
BTW, your interrupt handler above should not talk to the INTC device. There is a top level ISR above yours which talks to it. Your ISR is called by the top level ISR and should reset the interrupt in your device.
Since it sounds like you did not include the Device ISC, you only need the following two lines in your ISR to reset the interrupt in your device;
IpStatus = your_device_name_mReadReg(baseaddr, your_device_name_INTR_IPISR_OFFSET);
your_device_name_mWriteReg(baseaddr, your_device_name_INTR_IPISR_OFFSET, IpStatus);
Of course, you would need whatever other processing your ISR needs to do after reseting the IP interrupt(s). And you read the register to get the status of what interrupts occurred. The device supports up to 32 interrupts so you would process them as needed in this ISR.
FV
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-01-2009 01:32 AM
Thank you very much for your knowledge FV. I have learned how to use the core drivers, made another EDK project from start, and it all went OK. Note, however that in this version removed the ISC (as before), and didn't needed to change nothing in the driver's code. wonder why..?
Best,
JM
Re: Interrupt Handler not running, why?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-01-2009 06:21 AM
Your welcome. I went through the same issues not that long ago.
Not sure about why you would not need to change the driver. Did you do Create New Template in the Wizard or just Import the old one? The only other thing I could think of is that maybe it had the same name and did not overwrite the drivers that were already there.
It doesn't make sense to me, so, I would try to understand why/what happened. Look in your 'device_name.vhd' file in your '...\pcores\device_name\hdl\vhdl' directory. There is a constant named INTR_INCLUDE_DEV_ISC. If it is false, then it excluded the Device ISC. If this is true, that would explain it. If it is false, look at the driver to see if it has the statement that was causing the problem before.
Anyway, glad it is working. Good luck with the rest.
FV











