IPB

Welcome Guest ( Log In | Register )

> 'serious' Stack Warning Calling Function
fred
post Dec 10 2007, 02:42 PM
Post #1


Enthusiast
**

Group: EstablishedMember
Posts: 100
Joined: 1-December 06
From: Netherlands
Member No.: 2,116



Hi

the linker generates a serious stack warning because I have a function which is called within the handling of a rb0 interrupt and also in the program main loop. I can imagine that this can cause problems when the function is called by the interrupt routine and within the main() loop at the same time.

But under specific conditions the rb0 interrupt handler (which contains that function call) is disabling it's interrupt and activates a flag. Depending on that flag the mentioned funtion is called in the main loop.

So that function, referred to in the warning, can never be called in the interrupt routine at the time itīs also being executed because of a call within the main loop!

This is still all tricky or itīs not a problem to ignore this warning under this conditions?

little 'pseudo code' illustrates what's happening and causes the warning to be generated
CODE
void interrupt( void ) {
//falling edge portB.0
if( intcon & (1<<INTF) ) {        
    if ( switchPort ==  1 ) {
       Rb0Handler();
      activateDoSomething= 1;
       clear_bit( intcon, INTIE );   // disable this interrupt!
    }
    else MyRoutine();

    clear_bit( intcon, INTF ); //clear INTIE  interrupt bit
    }  // if INTF
return;
}
////////////////////////////

void main() {
init();
activateDoSomething= 0;
set_bit( intcon, INTIE );    

while( 1 ) {

    if ( activateDoSomething )  {
        DoSomething();
        MyRoutine();
        activateDoSomething= 0;
        set_bit( intcon, INTIE );    // enable that interrupt again
    } // if

}  // while

} // main
update SourceBoost release 6.97 is available.
Download Now
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
Dave
post Dec 10 2007, 07:28 PM
Post #2


Super Maniac
*****

Group: Administrators
Posts: 1,830
Joined: 28-September 04
From: UK
Member No.: 469



fred,
QUOTE (fred @ Dec 10 2007, 02:42 PM) *
Hi

the linker generates a serious stack warning because I have a function which is called within the handling of a rb0 interrupt and also in the program main loop. I can imagine that this can cause problems when the function is called by the interrupt routine and within the main() loop at the same time.

But under specific conditions the rb0 interrupt handler (which contains that function call) is disabling it's interrupt and activates a flag. Depending on that flag the mentioned funtion is called in the main loop.

So that function, referred to in the warning, can never be called in the interrupt routine at the time itīs also being executed because of a call within the main loop!

This is still all tricky or itīs not a problem to ignore this warning under this conditions?
If you are sure you are handling this situation correctly you can ignore this warning, your code looks like it maybe ok, but this kind of code can be tricky to understand.

Regards
Dave
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 3rd September 2010 - 02:48 PM