clear stack of arduino duemilanove

i am calling a no. of functions in my program...:) please tell me how 2 clear the program stack (memory) of arduino

my program calls around five functions recursively.. in the sense that

func1->func2->func3->func4->func5->func1

hence there may be a case of stack overflow... as far as i know the position of the calling func gets saved in the program stack and is cleared when the control comes back from the called func. but in my case, called func calls the calling func.. hence there may not be a chance to clear the stack.. will this create problems? in the sense will the arduino RAM hold?

if not plz tell me sum way to force clear the stack

The top entry on the stack is cleared by returning from the function. The stack is NOT a scrap area that you can indiscriminately clear.

If you are having problems with recursive calls, you need to work out those problems, instead of trying to "clear the stack".

Just so that you are aware, there is data pushed onto the stack for the function return point, and all the variables being "passed" to the called function. Clearing the stack would lose the return to address of the first function called, and leave your program hosed, anyway.

Yes, I agree with PaulS.

The question you asked indicates you probably have an algorithm that is not well-formulated. If you are not returning properly from many function calls, than you likely are not solving the problem correctly.

If you'd like to describe your problem a little more, I'm sure people here would be happy to advise you on algorithm strategies!

.andy

yup i dunno wt happnd to me... i revised my code and it seems to be working now.. thanks every1