Skip to main content
Visitor II
June 6, 2003
Question

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

  • June 6, 2003
  • 2 replies
  • 861 views
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

    tcrepinAuthor
    Visitor II
    June 6, 2003
    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

    }
    Visitor II
    June 6, 2003
    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