i am facing a wierd problem.. My MCU P89V51RD2BN resets during Execution... i am a college student and a beginner Here so i dont know the Advanced Programming methods i would also inform that..
i have a recursive function , a warning is issued by the compiler for the same. but....
earlier this was not a problem but since i have modified some of the Sub-Routines for 16Bit Data this Problem has come up, i need those functions to be 16 bit because of the limitation of the ALU i was earlier using 8bit and leaving most of the Task to Assumption which i cannot do so now..
i would also state that the Problem occurs in a fumction at a point when i call 2 functions in the same code, these themselves call around 5 sub-routines each but that wasnt a problem earlier (before i used the 16bit return type sub-routines).
now i found something in the manual stating reentrant Functions, but i really dont know how to use it
i used it like this
void Home_Screen_Instance() reentrant { ------------ } Do i need to use the keyword "reentrant" in the Function Decleration too? but that didnt help either but the compilers shows an error Home_Screen_Instance : redefinition. Target Not Created
this was the first of a kind problem that i encountered, my MCU is resetting itself for sure(i checked that with a dummy subroutine of blinking LED) and it is not because of the watchdog timer, i am sure about that too..
so whats the Problem here?
is the Stack overflowing??? or there is any other reason behind this? should i revert back to the 8bit versions of my subroutine (without any other choice)? is it because of the recursive nature of the function H0me_screen_instance?
Related Data:
The Program is Display intensive, i mean there are a lot of Strings to be displayed and they are stored beforehand in XDATA, message shown during sucessfull compilation, (still resets) Program Size: data 9.4 xdata 252 code 9514 creating hex-----blah blah blah---- 0 Error(s) 65 Warning(s)
"i am still figuring out a way to eliminate it..."
Wouldn't removing the recursion help out? Or does that feel like a too simple solution?
Note that any recursive algorithm can be rewritten into a non-recursive.
Don't you think i know the limitation of an embedded Processor...
and if i could have written the code in non-recursive form i would have written it... moreover i understand what you are trying to convey.
my recursive function has no local data, so the stack shall have return adresses only i suppose...
im still working on a way to write the code in a non recursive format!!
and please be a little "encouraging", just because you have so much knowledge about a platform doesn't mean you come hard on those who dont.
"Don't you think i know the limitation of an embedded Processor..."
No, I don't think you do. Or you wouldn't have used the term "an embedded processor". There aren't "one" embedded processor. Different processors have different limitations. And no - I do not thing you have grasped all limitations of the 8051 architecture yet - and exactly what it implies to C code or what steps a C compiler has to take to try to circumvent some of the limitations.
"and if i could have written the code in non-recursive form i would have written it..." In this case, I'm not even convinced you know the difference between recursive or non-recursive, based on your comments in a different post.
If I'm wrong and you really do use a recursive algorithm - please tell which. As I said - all recursive algorithms can be rewritten as non-recursive. If nothing else, then by the use of an array to store state information - i.e. the code itself stores the current state. An example is how a recursive-descent parser recursively calls higher-prioritized functions to process expressions. Compared to a state-driven parser that looks at current state and current token(s) to decide if more state should be pushed, or if enough information have been retrieved that one or more state entries could be reduced.
We just can't help you based on what information you do not post.
All we can do is see what you do post - and you do tell us that you are ignoring issues found by the compiler.