This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem about function calling in ISR

I call some sub-routine in ISR. And I mark the ISR as "using 1". But I find out this will lead to the error of parameters passing from ISR to the sub-routine. How come?

Parents
  • Erik,

    That is not the best way. Each function that has a using will save the PSW on the stack (which is a waste). Restoring the PSW from the stack destroys any return value of type bit. Using REGISTERBANK is simpler.

    For example:

    #pragma REGISTERBANK(1)
    
    bit functionone(void)
    {
        return( 1 );
    }
    
    void functiontwo( char c )
    {
        ...
    }
    
    myISR interrupt n using 1
    {
        if( functionone() ) functiontwo( 'c' );
    }
    

Reply
  • Erik,

    That is not the best way. Each function that has a using will save the PSW on the stack (which is a waste). Restoring the PSW from the stack destroys any return value of type bit. Using REGISTERBANK is simpler.

    For example:

    #pragma REGISTERBANK(1)
    
    bit functionone(void)
    {
        return( 1 );
    }
    
    void functiontwo( char c )
    {
        ...
    }
    
    myISR interrupt n using 1
    {
        if( functionone() ) functiontwo( 'c' );
    }
    

Children