Thomas Haupt
09/08/2014 5:57 AM
post111672
|
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
|
|
|
mario sangalli
09/08/2014 6:15 AM
post111673
|
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
|
|
|