Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Calling functions in Interrupts

Status
Not open for further replies.

movie_freak

Member level 5
Joined
Mar 20, 2007
Messages
89
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Activity points
1,943
Hi all,

How safe it is to call a function within the interrupt?


I have an event which needs to run as soon as it is recognized. It gets recognized in the interrupt.

Now, if I am executing somewhere in the main(); the program execution will recognize the event in the interrupt but only execute when it gets its chance in the Main.

As this event needs to be processed as soon as it gets recognized and it is the highest priority event that i want to process, can we call it in the Interrupt itself (and disabling further interrupts during the execution of this function to stop nesting of interrupts), or is there any other alternative method??


Note: This event need to be processed at real time with fast response. I am not using any RTOS it's only a ATmega based project.

Many Thanks,
Surya
 

movie_freak said:
Hi all,

How safe it is to call a function within the interrupt?


I have an event which needs to run as soon as it is recognized. It gets recognized in the interrupt.

Now, if I am executing somewhere in the main(); the program execution will recognize the event in the interrupt but only execute when it gets its chance in the Main.

As this event needs to be processed as soon as it gets recognized and it is the highest priority event that i want to process, can we call it in the Interrupt itself (and disabling further interrupts during the execution of this function to stop nesting of interrupts), or is there any other alternative method??


Note: This event need to be processed at real time with fast response. I am not using any RTOS it's only a ATmega based project.

Many Thanks,
Surya

Hi,
You dont have to CALL the so called 'event'. Just write ISR routine to service the event and return.It is really a bad idea to call functions from interrupt service routine.That too, when you say you need real time response..




Ciao,
Shiva
 

Thanks Shiva that's doable..

But in case the event itself need to wait or it needs a delay of say some 200 ms.. Is it still okie?? to do in this way??

and in this case do I need to disable interrupts while servicing the event?? Will this work??
 

movie_freak said:
Thanks Shiva that's doable..

But in case the event itself need to wait or it needs a delay of say some 200 ms.. Is it still okie?? to do in this way??

and in this case do I need to disable interrupts while servicing the event?? Will this work??

Hi,
It actually depends upon your application.What if you get an higher priority interrupt while servicing this..?
I dont know.. U decide..:D


Regards,
Shiva
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top