[SOLVED] Call function in Interrupt Routine

Status
Not open for further replies.

M.Rehan

Full Member level 2
Joined
Feb 10, 2016
Messages
129
Helped
2
Reputation
66
Reaction score
33
Trophy points
28
Activity points
972
Is it better to call a function in interrupt routine which has large instructions as given below

Code:
Interrupt_1()
{
Function();
}


Interrupt_2()
{
 Func_2();
}

void Function_1()
{
 PORTA=0;
 PORTB= 0;
 Delay_ms(1000);
 and further code
}


void Func_2()
{
 PORTA=0;
 PORTB= 0;
 Delay_ms(1000);
 and further code


My questions are if interrupt_1() calls function_1()
and is executing(not completed yet) and then interrupt_2 occurs.

1. will it handle interrupt_2 Routine leaving Function_1
2. After calling func_2() Which function will be executed first function_1() or Func_2() by keeping above scenario in mind

both interrupts have same priority


;-) Have a Good Day
 

Is it better to call a function in interrupt routine which has large instructions

Absolutelly, no; Insertion of delays in isr coutines is a bad practice.

I would say that the exact answer for all your questions is core dependent ( how many isr vector available ) and compiler dependent ( there is no instruction on the above code to handle any isr register ).
 

Insertion of delays in isr Routines is a bad practice.
That is reason I want to call function inside ISR routine so that Delays are not in ISR and could be handled outside ISR

Compiler: MIkroC and MPLAB
 
Hi,

it is the same when you run usual code inside ISR or "call a function inside ISR"

--> do the processing outside the ISR = main loop

Klaus
 
Reactions: M.Rehan

    M.Rehan

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…