We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Since the c51 compiler does not support the recursive call of a function is there any way to find out on which address location the function which is to be called as a recursive is located?
That is, is there any way to implement the recursive call funtion in a similar way of a software reset i.e just call like this ,
((void (code *) (void)) 0x0000) ();
The tools do support recursion. Just declare the function with the reentrant keyword. See the manual for configuring the software stack.
Note that there is signficant overhead for using this feature. The 8051 architecture is pretty bad at indirect references (such as those needed to use parameters/locaks on a stack) and the compiler doesn't get to do its nifty data overlaying optimizations.
The name of the function is the address of the start of the function. It's a pointer. I don't think that will really help you, though, unless the body of the function generated by the compiler understands that it can exist multiple times at once and so includes code to look on a stack for parameters, locals, etc.
I declared the functionas reentrant but then also i got the warning L13: Recursive call to segment.
I am not much familiar with the configuring of the software stack.
Can i know what are the things needed to taken care when doing a software stack adjustment and how it is done?
For the stack, you just need to make sure that you _have_ a stack. See the manual and STARTUP.A51 to configure it.
The function to call as recursive i declared it as reentrant.
Then i added the startup.a51 to my project and in that file i changed the setting of,
XBPSTACK EQU 1
Then saved the file and compiled but then to i get the warning L13: Recursive call to segment.
Do i need to set some other thing to avoid this warning message?
What is the complete error that the linker gives you? The reason I ask is because the complere linker error lists the function that it thinks is called recursively.
If you create a reentrant function that calls other functions that are not reentrant, you may receive this error.
Jon
***Warning L13: RECURSIVE CALL TO SEGMENT SEGMENT : ?PR?_?DEVICE_ID?MAIN CALLER : ?PR?TOTAL_DEVID?MAIN
This is the warning message. Actually the reentrant function is Device_ID().My function look like this,
void Device_ID(void) reentrant { . . func1(); . . func2(); . . }
void func1(void) //this is not reentrant { . . }
void func2(void) //this is not reentrant { . . func3(); . . }
void func3(void) { . . Device_Id(); //in this function only i call the //reentrant function . . }
I already told that the setting i did in the startup.a51.
Now what should i do?
Then i added the startup.a51 to my project and in that file i changed the setting of,<p>
You need to check which memory model the function is using (there's three of them: small, large and compact). Each of these has their own stack.
The memory model is Large.
The setting is done in the reentrant stack intialisation of the startup.a51 for large model.
XBPSTACK EQU 1 XBPSTACKTOP EQU 0FFFFH+1;
My microsontroller is P89c51RD2HBP, and i have external RAM of 8KB.
For the above microncotroller what should be done?
If i have 8031 with 64KB external EPROM and 8KB external RAM what should be the setting done?
If you call other functions from your reentrant function, they should be declared reentrant, too (unless you really know what you're doing) - otherwise, there could be multiple instances of the called functions active at the same time.
All the functions inside my reentrant functions are declared as reentrant.
After compiling the project still the warning message is coming.
Any suggestions what to do to eliminate this warning?
func1, func2 and func3 ?
All functions that could possibly have more than one instance of themselves running need to be declared reentrant.
Yes, the
func1(),func2(),func3() also declared as reentrant.
Then too the warning message is coming.