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: 
Highlighted
8,376 Views
Registered: ‎02-16-2012

IIC + Interrupts = microblaze crash

Jump to solution

Hello everyone,

 

Using an o-scope, I see my Spartan6 putting out clean 3.3V "clock" and "data" I2C signals to the slave device. All is well with the UCF file and external pull up resistors.

 

However, when the slave acks the address, the resulting interrupt causes the microblaze to "reboot" itself back into main() <insert grumble here!>

 

I have read many postings here related to making IIC work, but none seem to cover my particular problem. I have very carefully adapted the "hello_iic/xiic_eeprom_example.c" from the SP605 eval board. Of course, this example requires the INTC device, so I added that in as well and hooked up the required interrupt lines. I have read others saying the INTC device is not needed for a single interrupt, but my hands are tied since I am trying to hew closely to the example code.

 

When I attach the debugger and run the ELF, things are a little difference. The system hangs instead of rebooting. So I hit the "pause" button to discover the rpc register (microblaze program counter) is at 0x10, clearly a bad low address. So my only lead at this point is that the interrupt is causing a jump to this invalid address.

 

One concern I have is the eval board's project uses the "PLB" bus for everything (IIC and INTC devices) but my project is based on the newer AXI bus standard. Could the example code not be AXI ready? Does that statement even make sense?

 

Any ideas to try would be welcomed.

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
10,454 Views
Registered: ‎02-16-2012

Re: IIC + Interrupts = microblaze crash

Jump to solution

 

FInally figured it out- problem came from following the suggestion in this post:

 

http://forums.xilinx.com/t5/Embedded-Development-Tools/Removing-Unused-functions-from-Assembly-Code/m-p/54762

 

This optimization causes the linker to strip out the "interrupt_handler" from the ELF and that is why it was crashing upon any interrupt.

 

I removed the "-Wl,-gc-sections" option from my linker options and all is well now. Thanks for pointing me in the right direction!

 

 

0 Kudos
4 Replies
Mentor hgleamon1
Mentor
8,366 Views
Registered: ‎11-14-2011

Re: IIC + Interrupts = microblaze crash

Jump to solution

A quick check of the Microblaze Processor Reference Guide reveals that address 0x10 is the vector address for interrupts, so this is exactly how I would expect the processor to behave.

 

The question is, then, how are you handling this interrupt? i.e. what does your interrupt handler do?

 

Follow up questions may also be: is the interrupt TO THE MICROBLAZE edge or level sensitive? Is the interrupt from the IIC to the INTC edge or level sensitive? How quickly do you deassert/acknowledge the interrupt source when servicing the interrupt?

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos
8,354 Views
Registered: ‎02-16-2012

Re: IIC + Interrupts = microblaze crash

Jump to solution

Thanks- I think you're right. After studying page 64 of the "MicroBlaze Processor Reference Guide" it is clear an interrupt handler needs to be installed at 0x10.

 

I stepped through the interrupt setup code I lifted from the example, and no changes were ever made to 0x10. It is still set to NULL, which is very likely my problem.

 

So now I am confused; what API call is supposed to change this all importand address? Here is my interrupt setup code:

 

 

static int SetupInterruptSystem(XIic * IicInstPtr)
{
  int Status;

  if (InterruptController.IsStarted == XCOMPONENT_IS_STARTED) {
      return XST_SUCCESS;
  }

  /*
   * Initialize the interrupt controller driver so that it's ready to use.
   */
  Status = XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID);
  if (Status != XST_SUCCESS) {
      return XST_FAILURE;
  }

  /*
   * Connect the device driver handler that will be called when an
   * interrupt for the device occurs, the handler defined above performs
   * the specific interrupt processing for the device.
   */
  Status = XIntc_Connect(&InterruptController, XPAR_INTC_0_IIC_0_VEC_ID,
      (XInterruptHandler) XIic_InterruptHandler, IicInstPtr);
  if (Status != XST_SUCCESS) {
      return XST_FAILURE;
  }

  /*
   * Start the interrupt controller so interrupts are enabled for all
   * devices that cause interrupts.
   */
  Status = XIntc_Start(&InterruptController, XIN_REAL_MODE);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  /*
   * Enable the interrupts for the IIC device.
   */
  XIntc_Enable(&InterruptController, XPAR_INTC_0_IIC_0_VEC_ID);

  /*
   * Initialize the exception table.
   */
  Xil_ExceptionInit();

  /*
   * Register the interrupt controller handler with the exception table.
   */
  Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
                           (Xil_ExceptionHandler) XIntc_InterruptHandler,
                           &InterruptController);

  /*
   * Enable non-critical exceptions.
   */
  Xil_ExceptionEnable();

  return XST_SUCCESS;
}

 Am I missing a required API call?

 

Thanks again!

0 Kudos
Mentor hgleamon1
Mentor
8,350 Views
Registered: ‎11-14-2011

Re: IIC + Interrupts = microblaze crash

Jump to solution

I don't think you are missing any function calls. However, I am not convinced by the way you have used the Connect and Enable calls.

 

You use the parameter XPAR_INTC_0_IIC_0_VEC_ID. What integer value does this have? You should use the integer value of the number of the interrupt connected to the INTC IP, i.e. if you only have one interrupt connected, this value will enumerate to 0.

 

The parameter you require should be lifted from the xparameters.h file found under your bsp/microblaze/inlude directory. You may have to search for it.

 

I don't think that you are connecting and enabling the correct interrupt (maybe you are, I can't see your system.mhs) and this could be why the system hangs on an interrupt condition.

 

The final question is: what does the handler do?

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos
10,455 Views
Registered: ‎02-16-2012

Re: IIC + Interrupts = microblaze crash

Jump to solution

 

FInally figured it out- problem came from following the suggestion in this post:

 

http://forums.xilinx.com/t5/Embedded-Development-Tools/Removing-Unused-functions-from-Assembly-Code/m-p/54762

 

This optimization causes the linker to strip out the "interrupt_handler" from the ELF and that is why it was crashing upon any interrupt.

 

I removed the "-Wl,-gc-sections" option from my linker options and all is well now. Thanks for pointing me in the right direction!

 

 

0 Kudos