cancel
Showing results for 
Search instead for 
Did you mean: 

Calling the same function within a main routine and an interrupt routine

tcrepin
Associate
Posted on June 06, 2003 at 10:50

Calling the same function within a main routine and an interrupt routine

2 REPLIES 2
tcrepin
Associate
Posted on June 06, 2003 at 10:09

I would like to call a function with arguments both into the main and an interrupt routine. Is this possible ? How can I be sure that the arguments are not corrupted in case the interrupt routine interrupts the main routine ? Or in other words is it possibles to pass the arguments through the stack instead of through memory or registers?

(I USE HIWARE COMPILER)

See the following example:

void main void

{

while (1)

{

fct (arg1,arg2);

}

}

#pragma TRAP_PROC SAVE_REGS

void interrupt 12 it_sci (void)

{

.......

fct (arg1,arg2);

.......

}

#pragma NO_OVERLAP

void fct (int arg1,int arg2)

{

SIM

// do something with arg1;

.......

// do something with arg2;

.......

RIM

}
drumfirex
Associate II
Posted on June 06, 2003 at 10:50

I think you should disable interrupts at the first line of ''fct'' function and then enable them at the exit.

Patrik