Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 851
  • Last Modified:

Interrupt on PPC440 with a custom IP problem

Hi,

 

i'm trying to use interrupt with my cunstom IP.

My architecture is :

- PP440 master on PLB0, PPC400 slave on PLB1

- Central DMA master on PLB1, Central DMAslave on PLB0

- Custom IP slave on PLB1

- TEMAC, Uart, Timer, Xint slave on PLB0

- I also use the lwip library

 

I follow this tutorial (http://www.fpgadeveloper.com/2008/10/timer-with-interrupts.html) to create a custom IP with interruption, just in my case the Custom IP VHDL code is a bit different since i don't need a timer.

 

After in XPS in order to setup the interuption i wrote this code (the code in the bellow tutorial seems to be for microblaze):

 

in my main before the while(1):

    // Initialize Interrupts on PowerPC
    XExc_Init();


    // Register the interrupt handler of the XPS Interrupt Controller with the PowerPC's external interrupt.
    xil_printf("  - Enabling XPS interrupts\r\n");
    XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_DeviceInterruptHandler, (void *)XPAR_XPS_INTC_0_DEVICE_ID);


    // Register the Switch Debouncer interrupt handler in the vector table of the XPS Interrupt Controller
    xil_printf("  - Registering interrupt handler\r\n");
    XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, XPAR_XPS_INTC_0_CUSTOM_READ_FIFO_0_IP2INTC_IRPT_INTR, (XInterruptHandler)CUSTOM_READ_FIFO_Intr_Handler, (void *)XPAR_CUSTOM_READ_FIFO_0_BASEADDR);


    // Start the XPS Interrupt Controller
    xil_printf("  - Enabling interrupts\r\n");
    XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR);


    // Enable Switch Debouncer interrupt requests in the XPS Interrupt Controller
    XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, XPAR_CUSTOM_READ_FIFO_0_IP2INTC_IRPT_MASK);


    // Enable custom fifo read interrupts
    xil_printf("  - Enabling CUSTOM_READ_FIFO interrupts\r\n");
   CUSTOM_READ_FIFO_EnableInterrupt(Custom_Read_Fifo);


    // Enable PowerPC non-critical (external) interrupts
    XExc_mEnableExceptions(XEXC_NON_CRITICAL);

 

then the callback interrupt on another file :

void CUSTOM_READ_FIFO_Intr_Handler(void * baseaddr_p)
{
xil_printf("  - CUSTOM_READ_FIFO_Intr_Handler received \r\n");
}

 

The first problem is when i run this code (compile without error) i no more able to connect to the FPGA by LAN. i meen the callback function tcp_accept seems to not work anymore.

 

Can some could help me and give advice  ? does the interrupt setup is wrong ??

 

Thank you
0
DBTechnique
Asked:
DBTechnique
  • 3
1 Solution
 
DBTechniqueAuthor Commented:
Here is my new test with an example timer that i found on internet. If i check the value of the timer interrupt with the line xil_printf (on the while(1)) i can see on the uart that the value is 0 and then become 1 so the timer is working and his interrution too. But i still never go to the "void MY_TIMER_Intr_Handler(void * baseaddr_p)".
why? what did i miss on the setup ?
Please help me.


#include "xparameters.h"
#include "xbasic_types.h"
#include "xgpio.h"
#include "xstatus.h"
#include "my_timer.h"
#include "custom_read_fifo.h"
#include "xintc.h"
#include "xexception_l.h"

#define TIMER_RESET   0x00000000
#define TIMER_RUN     0x40000000
#define TIMER_EXPIRED 0x80000000
#define TIMER_HALFSEC 0x02FAF080

XIntc InterruptController;
Xuint32 my_timer;
unsigned int *my_timer_p = (unsigned int *) XPAR_MY_TIMER_0_BASEADDR;
//unsigned int *my_custom_read_fifo_p = (unsigned int *) XPAR_CUSTOM_READ_FIFO_0_BASEADDR;

//----------------------------------------------------
// INTERRUPT HANDLER FUNCTION
//----------------------------------------------------
//void CUSTOM_READ_FIFO_Intr_Handler(void * baseaddr_p)
//{
//      xil_printf("  - fifo Interrupt is working !!!!!!!!!!!!!!!!!!!!\r\n");
//}
void MY_TIMER_Intr_Handler(void * baseaddr_p)
{
      xil_printf("  - timer Interrupt is working !!!!!!!!!!!!!!!!!!!!\r\n");
}

//----------------------------------------------------
// MAIN FUNCTION
//----------------------------------------------------
int main (void)
{
      XStatus Result;
      
      //Initialize the interrupt controller driver so that it's ready to use.
   Result = XIntc_Initialize(&InterruptController, XPAR_XPS_INTC_0_DEVICE_ID);
   if (Result != XST_SUCCESS){return Result;}xil_printf("  - Enabling XPS initialize\r\n");
      
      //Perform a self-test to ensure that the hardware was built correctly.
   Result = XIntc_SelfTest(&InterruptController);
   if (Result != XST_SUCCESS){return Result;}xil_printf("  - Enabling XPS SelfTest\r\n");

//   //Register the handler for fifo
//   Result = XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_CUSTOM_READ_FIFO_0_IP2INTC_IRPT_INTR, (XInterruptHandler)CUSTOM_READ_FIFO_Intr_Handler, my_custom_read_fifo_p);
//   if (Result != XST_SUCCESS){return Result;}xil_printf("  - Enabling XPS connect fifo\r\n");
      //Register the handler for timer
   Result = XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_MY_TIMER_0_IP2INTC_IRPT_INTR, (XInterruptHandler)MY_TIMER_Intr_Handler, my_timer_p);
   if (Result != XST_SUCCESS){return Result;}xil_printf("  - Enabling XPS connect timer\r\n");
 
   //Start the interrupt controller so interrupts are enabled for all devices that cause interrupts.
   Result = XIntc_Start(&InterruptController, XIN_REAL_MODE);
   if (Result != XST_SUCCESS){return Result;}xil_printf("  - Enabling XPS start\r\n");

//      //Enable the interrupt for the CUSTOM_READ_FIFO device
//   CUSTOM_READ_FIFO_EnableInterrupt(my_custom_read_fifo_p);
//   xil_printf("  - Enabling XPS fifo\r\n");
      //Enable the interrupt for the MY_TIMER device
   MY_TIMER_EnableInterrupt(my_timer_p);
   xil_printf("  - Enabling XPS timer\r\n");

      // Start the interrupt controller
      XIntc_mMasterEnable(XPAR_MY_TIMER_0_BASEADDR);
      XIntc_mEnableIntr(XPAR_MY_TIMER_0_BASEADDR, XPAR_MY_TIMER_0_IP2INTC_IRPT_MASK);

   //Initialize the PPC440 exception table
   XExc_Init();
   xil_printf("  - Enabling XPS xexc init \r\n");

   //Register the interrupt controller handler with the exception table
   XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_InterruptHandler, &InterruptController);
      xil_printf("  - Enabling XPS handler exeption\r\n");

   //Enable non-critical exceptions
   XExc_mEnableExceptions(XEXC_NON_CRITICAL);
   xil_printf("  - Enabling XPS enable exeption\r\n");
      
      //----------------------------------------------------
      // INITIALIZE THE TIMER PERIPHERAL
      //----------------------------------------------------
      xil_printf("  - Initializing the timer peripheral\r\n");
      // Check that the my_timer peripheral exists
      XASSERT_NONVOID(my_timer_p != XNULL);
      my_timer = (Xuint32) my_timer_p;
      // Load the delay register with the delay time of 0.5s
      MY_TIMER_mWriteSlaveReg0(my_timer, 0, TIMER_HALFSEC);
      // Start the timer
      xil_printf("  - Starting the timer\r\n\r\n");
      MY_TIMER_mWriteSlaveReg1(my_timer, 0, TIMER_RUN);

      
      while(1){
      //xil_printf("Timer interrupt vslue : %d\r\n", MY_TIMER_mReadReg(my_timer, MY_TIMER_INTR_IPISR_OFFSET));
  }
}

0
 
DBTechniqueAuthor Commented:
i found out
0
 
DBTechniqueAuthor Commented:
i found out, if someone wants to know i just replace lines :

   // Start the interrupt controller
    XIntc_mMasterEnable(XPAR_MY_TIMER_0_BASEADDR);
    XIntc_mEnableIntr(XPAR_MY_TIMER_0_BASEADDR, XPAR_MY_TIMER_0_IP2INTC_IRPT_MASK);

 

by

// Start the interrupt controller
    XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_DEVICE_ID);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now