I have a large structure I wish to locate in code space. The problem appears to be the linker intreprets the accesses to this structure as a subroutine call. I get the error "Too many recursive calls to segment...". The structure works fine in XDATA. It also worked fine in code space until there were enough routines accessing the structure. Anyone have a clue?
This is one area where the compiler is not as smart as I might wish it to be. Everything in a single .c file goes into the same segment, and that segment name is the unit of granularity for tracking references. I run into the problem a lot with code that has the structure:
// Cmd.c const code Strings[]; void Cmd1 () { printf (Strings[0]); } void Cmd2 () { printf (Strings[1]); } const code CmdTbl[] = { Cmd1, Cmd2 }
Thanks for the tip(s). I really want this structure in code space. It is the heart of a complex menuing system and I don't want take any chances that it may get corrupted. Again thank you for taking the time to answer.
"I really want this structure in code space ... I don't want take any chances that it may get corrupted." So the true requirement here is to have it read-only, yes? Placing it in code space is merely a means to that end? Is your memory architecture such that you can map (some of) a ROM into XDATA space? If so, you could look at XCONST as an alternative solution to your requirement.
You are correct. Read only is the goal. Can't do any re-mapping. I am using a Cygnal 8051 type processor. The flash and RAM are internal and fixed. By the way, I have looked high and low for a way to turn off the recursion errors. I have not found it yet. Thanks again.
Have you tried the manual? http://www.keil.com/support/man/docs/c51/c51_xf_recursivecode.htm Jon
Ah! The old read the manual routine. This is great; however, I have about 200 references to my structure, from 60 or so subroutines. This does not seem like a very user friendly solution. This may be what I have to do, .... doesn't mean I have to like it. I have never run into this problem before using the Keil compiler. I do embedded systems "stuff" (obviously) and it is very common to place structures in the code space. Thanks for the pointer.
Is the error message this one?
FATAL ERROR 232: APPLICATION CONTAINS TOO MANY RECURSIONS.
That the one. I will take a look as soon as I can figure our where the macro assembler book is hidden. Short term memory problems as well. Thanks a bunch to all who have responded. Perhaps someday I can reciprocate.
You may use OVERLAY (segname ! *) to exclude the segment from overlay analysis. That's all you'll need to do. The segment name will be something like ?CO?filename. Jon
See on-line document here: http://www.keil.com/support/man/docs/lx51/lx51_recursions.htm
Thanks again. I found my book and tried bumping the recursions to 200 and it works. My cup runneth over with information. (I have mail) Here comes some more!
Wow, I love this country. I ask for a little help and all you generous, kind people, offer up an abundance of information. Thanks to all.
"Wow, I love this country." Which country? So far, you have answers from at least two Continents! :-)
"Which country?" America, of course. The third world doesn't have internet. Besides, all the replies were in English, they must be from Americans. The only other people who can speak it are the Brits, but see the note above about the third world. Stefan
"The only other people who can speak it are the Brits" Yes, but the only people who can spell it are the Brits! ;-)