cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
553 Views
Registered: ‎05-22-2018

How to switch from MicroBlaze standard to fast interrupt

I have a working design with Microblaze which uses an interrupt:

 

void InterruptServiceRoutine1(void *InstancePtr)
{
   printf("InterruptServiceRoutine 1\n\r");
}

void InterruptServiceRoutine2(void *InstancePtr)
{
   Watchdog *Watchdog = &Watchdog::getInstance();

   printf("InterruptServiceRoutine Anfang 2\n\r");

   for (int i = 0; i < 4; i++)
   {
      Watchdog->trigger();
      usleep(500000);
   }

   printf("InterruptServiceRoutine Ende 2\n\r");
}

int main(int argc, char **argv)
{
   init();

   Watchdog *Watchdog;
   PowerSupply *PowerSupply;
   FPGA_ClockGenerator *ExternalClockGenerator;
   int Status;

   Watchdog = &Watchdog::getInstance();

   if (not systemInfo->isSimu)
   {
      printf("-- Start standard --\n\r");

      PowerSupply = &PowerSupply::getInstance();
      PowerSupply->switchOnDigital();

      msleep(10); // Wait until power is ramped up

      ExternalClockGenerator = &FPGA_ClockGenerator::getInstance();
   }

   mmapaccess->WritePara(100000000, RegMB_BC_MicroBlaze_IRP_Timer_IRP_Timer, 0);
   mmapaccess->WritePara(300000000, RegMB_BC_MicroBlaze_IRP_Timer_IRP_Timer, 1);

    Status = XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID);
    if (Status != XST_SUCCESS) {
      printf("Initializing interrupt controller failed\n\r");
    }

    Status = XIntc_Connect(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_0_INTR,
              (Xil_ExceptionHandler)InterruptServiceRoutine1, &InterruptController);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    Status = XIntc_Connect(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_1_INTR,
              (Xil_ExceptionHandler)InterruptServiceRoutine2, &InterruptController);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    Status = XIntc_Start(&InterruptController, XIN_REAL_MODE);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    XIntc_Enable(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_0_INTR);
    XIntc_Enable(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_1_INTR);

    Status = XIntc_Start(&InterruptController, XIN_REAL_MODE);
    if (Status != XST_SUCCESS) {
        return Status;
    }

   Xil_ExceptionInit();

   Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
      (Xil_ExceptionHandler)
      XIntc_InterruptHandler,
      &InterruptController);

   Xil_ExceptionEnable();

   main_loop(Watchdog);

   return 0;
}

 

---------------------------------------------------------------------

 

What do I have to do in oder to switch to fast interrupt mode? I set "Enable fast interrupt logic" in the Vivado Microblaze design. The design still works with no difference using the code above.

 

I'm using https://forums.xilinx.com/xlnx/attachments/xlnx/EMBEDDED/31646/1/main.c as a template for using fast interrupt mode. The code below doesn't work however. It prints "Before connect handler" then the watchdog runs into a timeout. What am I doing wrong?

 

void InterruptServiceRoutine1(void *InstancePtr) __attribute__((fast_interrupt));

void InterruptServiceRoutine1(void *InstancePtr)
{
   printf("InterruptServiceRoutine 1\n\r");
}

void InterruptServiceRoutine2(void *InstancePtr) __attribute__((fast_interrupt));

void InterruptServiceRoutine2(void *InstancePtr)
{
   Watchdog *Watchdog = &Watchdog::getInstance();

   printf("InterruptServiceRoutine Anfang 2\n\r");

   for (int i = 0; i < 4; i++)
   {
      Watchdog->trigger();
      usleep(500000);
   }

   printf("InterruptServiceRoutine Ende 2\n\r");
}

int main(int argc, char **argv)
{
   init();

   Watchdog *Watchdog;
   PowerSupply *PowerSupply;
   FPGA_ClockGenerator *ExternalClockGenerator;
   int Status;

   Watchdog = &Watchdog::getInstance();

   if (not systemInfo->isSimu)
   {
      printf("-- Start fast --\n\r");

      PowerSupply = &PowerSupply::getInstance();
      PowerSupply->switchOnDigital();

      msleep(10); // Wait until power is ramped up

      ExternalClockGenerator = &FPGA_ClockGenerator::getInstance();
   }

   mmapaccess->WritePara(100000000, RegMB_BC_MicroBlaze_IRP_Timer_IRP_Timer, 0);
   mmapaccess->WritePara(300000000, RegMB_BC_MicroBlaze_IRP_Timer_IRP_Timer, 1);

    Status = XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID);
    if (Status != XST_SUCCESS) {
      printf("Initializing interrupt controller failed\n\r");
    }

   printf("Before connect handler\n\r");
    Status = XIntc_ConnectFastHandler(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_0_INTR,
              (XFastInterruptHandler)InterruptServiceRoutine1);
   printf("After connect handler\n\r");
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    Status = XIntc_ConnectFastHandler(&InterruptController, XPAR_AXI_INTC_0_SYSTEM_INTR_1_INTR,
              (XFastInterruptHandler)InterruptServiceRoutine2);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

   XIntc_Start(&InterruptController, XIN_REAL_MODE);

   XIntc_Enable(&InterruptController, 0);

   Xil_ExceptionInit();

   Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
      (Xil_ExceptionHandler)
      XIntc_InterruptHandler,
      &InterruptController);

   Xil_ExceptionEnable();

   main_loop(Watchdog);

   return 0;
}

 

0 Kudos
2 Replies
Highlighted
Moderator
Moderator
498 Views
Registered: ‎07-31-2012

Re: How to switch from MicroBlaze standard to fast interrupt

Hi @qmarc,

 

Could you try the attached code?

 

Regards

Praveen


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
461 Views
Registered: ‎05-22-2018

Re: How to switch from MicroBlaze standard to fast interrupt

Thanks for the example design. It appears to be for Zynq, not for Microblaze however. For this reason fiqasm.S doesn't compile in my design. Is it available for Microblaze as well? Or in C instead of assembler?

 

Best Regards,

Michael

0 Kudos