Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - InterruptAttach(): (5 Items)
   
InterruptAttach()  
Hi All,
I have been developing a GPIO driver in QNX Neutrino 6.6 for IMX6Q processor
I am currently using the Saberlite BD_SL_IMX6 kit for the development and testing
Problem: Currently i am facing problem in writing an interrupt handler for the 
driver using the interrupt attach function. 
i am doing the following
defined a global variable
//I have put a global variable defined as a volatile integer type and have set it a value 5 and 
updated the variable in interrupt handler.
volatile uint32_t myVar ;

const struct sigevent *inthandler(void *area, int size)
{
//In the interrupt handler function if i return NULL the board is hanging and getting disconnected.
//If i remove the return NULL from the interrupt handler board is not hanging or disconnected.
   myVar+=myVar;
}
main()
{
//I have mapped the device io memory after a threadctl
   ThreadCtl()
   mmap_device_io()
   //configuring the MUX as GPIO
   //Then i have a function with the configuration of GPIO4_PIN5 as a GPIO and configuring 
it as an input DIR pin.Then i have configured the InterruptConfigurationRegister1 of the GPIO4 base address for 
the interrupt.I have done the masking for the GPIO4_PIN5 in the IMR.

   //GPIO configuring as input   
   //Configured the InterruptConfigurationRegister1 for pin 5 
   //Configured the InterruptMaskRegister for pin 5    
   //I am using the interruptattach function to attach the interrupt with the handler.
   //I have attached the interrupt line 104 for the getting interrupt for GPIO4 (signals 0-15).
   interruptret=InterruptAttach(104,inthandler,&dev,0,_NTO_INTR_FLAGS_PROCESS);
	 	if(interruptret==-1)
	 	{
	 	 printf("Interrupt Attach Error %d\n",interruptret);	 	 
	 	}
		while(1)
		{
		  //printing the status register value
		  //gloabal variable checking for update          		 
          //break if value of the global varible is > 100		  
		}
}

if i just return NULL from the ISR the processor hangs and disconnects but when i remove return the hanging problem is 
solved but i am not getting any interrupt as the variable update in the ISR is not happening but the status register 
keeps updating when i just poll the interrupt status register.
Please suggest if anybody could get something why this problem has occured. 
RE: InterruptAttach()  
Hi Praveen,

that sounds a bit odd. What do you return from your ISR if you do not return NULL? (After all, the ISR requires a return
 value)

Does your variable ever get printed in the main thread (i.e., do you reach the while loop at all)?

At what priority are you running this program? Perhaps you want to add a bit of delay to the loop.

Also, can you post the full source code?

Kind regards,
Thomas

-----Original Message-----
From: Praveen Kumar [mailto:community-noreply@qnx.com] 
Sent: Montag, 8. September 2014 11:22
To: ostech-core_os
Subject: InterruptAttach()

Hi All,
I have been developing a GPIO driver in QNX Neutrino 6.6 for IMX6Q processor I am currently using the Saberlite 
BD_SL_IMX6 kit for the development and testing
Problem: Currently i am facing problem in writing an interrupt handler for the driver using the interrupt attach 
function. 
i am doing the following
defined a global variable
//I have put a global variable defined as a volatile integer type and have set it a value 5 and updated the variable in 
interrupt handler.
volatile uint32_t myVar ;

const struct sigevent *inthandler(void *area, int size) { //In the interrupt handler function if i return NULL the board
 is hanging and getting disconnected.
//If i remove the return NULL from the interrupt handler board is not hanging or disconnected.
   myVar+=myVar;
}
main()
{
//I have mapped the device io memory after a threadctl
   ThreadCtl()
   mmap_device_io()
   //configuring the MUX as GPIO
   //Then i have a function with the configuration of GPIO4_PIN5 as a GPIO and configuring it as an input DIR pin.Then i
 have configured the InterruptConfigurationRegister1 of the GPIO4 base address for the interrupt.I have done the masking
 for the GPIO4_PIN5 in the IMR.

   //GPIO configuring as input   
   //Configured the InterruptConfigurationRegister1 for pin 5 
   //Configured the InterruptMaskRegister for pin 5    
   //I am using the interruptattach function to attach the interrupt with the handler.
   //I have attached the interrupt line 104 for the getting interrupt for GPIO4 (signals 0-15).
   interruptret=InterruptAttach(104,inthandler,&dev,0,_NTO_INTR_FLAGS_PROCESS);
	 	if(interruptret==-1)
	 	{
	 	 printf("Interrupt Attach Error %d\n",interruptret);	 	 
	 	}
		while(1)
		{
		  //printing the status register value
		  //gloabal variable checking for update          		 
          //break if value of the global varible is > 100		  
		}
}

if i just return NULL from the ISR the processor hangs and disconnects but when i remove return the hanging problem is 
solved but i am not getting any interrupt as the variable update in the ISR is not happening but the status register 
keeps updating when i just poll the interrupt status register.
Please suggest if anybody could get something why this problem has occured. 



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post111671
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Re: InterruptAttach()  
Il 08/09/2014 11:21, Praveen Kumar ha scritto:
> Hi All,
> I have been developing a GPIO driver in QNX Neutrino 6.6 for IMX6Q processor
>
Some code is missing from Your example:
Your ISR must return a signal or a NULL : if You don't return
a value, a impredictable value will be returned.
You have to wait for interrupt event using the InterruptWait or
You have to insert a polling delay in your main.

    struct    sigevent    isrvent;

     const struct sigevent *inthandler(void *area, int size)
     {
           if(any_interrupt){
               // Handle interrupt, clear it....

                return(&isrevent);    /* Awake waitInterrupt */
          }
           return(NULL);                 //
    }

main()
{


      // Init the sigevent
      event.sigev_notify= (SIGEV_INTR);
InterruptAttach(104,inthandler,&dev,0,_NTO_INTR_FLAGS_PROCESS);
      while(1)
      {
             InterruptWait(0,NULL);   // You must wait the interrupt

      //printing the status register value
      //gloabal variable checking for update          		
      //break if value of the global varible is > 100		
    }

Bye.
Mario

Re: InterruptAttach()  
Hi,
In the BSP for the iMX6DQ there is an information for the interrupt vectors in the "sabrelite.build" file. The GPIO 
vectors are from 160 -383 for the GPIO banks 1-7.The datasheet is having the vector number as 99-111 for the GPIO.
I have tried the both vectors using the interruptattach() function but i am not able to get my ISR called.
It is still the code i have posted before but tried with the vector number as 104 as per datasheet and 261 as per the 
BSP .
Re: InterruptAttach()  
Il 16/09/2014 12:23, Praveen Kumar ha scritto:
> Hi,
> In the BSP for the iMX6DQ there is an information for the interrupt vectors in the "sabrelite.build" file. The GPIO 
vectors are from 160 -383 for the GPIO banks 1-7.The datasheet is having the vector number as 99-111 for the GPIO.
> I have tried the both vectors using the interruptattach() function but i am not able to get my ISR called.
> It is still the code i have posted before but tried with the vector number as 104 as per datasheet and 261 as per the 
BSP .
Hi, You have to use the vectors from 160..383,  You can check the the 
init_intrinfo.c
for details. Use the _NTO_INTR_CLASS_EXTERNAL flag in the 
InterruptAttach ....
Of course, you have to use the vector of the GPIO You are using as 
Interrupt source...
Mario