Skip to main content
tcrepin
Associate
Jun 6, 2003 8:50 AM UTC
Question

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

Posted on June 06, 2003 at 10:50

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

This topic has been closed for replies.

2 replies

tcrepin
tcrepinAuthor
Associate
Jun 6, 2003 8:09 AM UTC
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
Jun 6, 2003 8:50 AM UTC
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