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.

[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
 
  • Like
Reactions: M.Rehan

    M.Rehan

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

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top