Hi Everybody!
I'm working on a project with a AT8C51RE2 and reached the maximum code size of 65K.
So i set up the code banking mechanism and split my programm to three banks.
Everythings works fine, only string handover between banks often give some chaotic results.
For example ive got an constant char code table in bank #1 like this one:
static const char code g_UnitDesignation[UnitDesignationId_LENGTH][MaxChar_UnitDesignation]= { {""}, {"s"}, {"min"}, {"days"}, {"mg/l"} }
if try to access over an function in common bank:
char* Log_GetLogText(UINT8 UnitDesignationId, float LogValue) { char outputString[Protocol_MaxOutputChars]; sprintf(outputString, "Log %s=%5.3f", Unit_getUnitDesignation(UnitDesignationId), LogValue); return outputString; }
the generated output is often mutilated badly. (".000Logä")
Does anybody have an idea how to handle this cross access over banks or have a hint whats going wrong?
Thanks a lot,
David
string handover between banks often give some chaotic results.
And on what basis did you even begin to believe that that could, much less should, work? That's code banking you're looking at, not constant data banking. String literals outside the common bank are, pretty much by definition, not accessible at all to code in any other bank than their own.
I rather strongly suspect the only possibly strategy here is "Don't do that, then!"
Thanks for your reply.
Refer to the manual: http://www.keil.com/support/man/docs/bl51/bl51_bk_commonarea.htm
Every code constant should be placed in the comman bank, unless you can guarantee that you operate in the same bank at the time of access.
So i try to transfer the code constant to string variable inside the bank and return it as a variable to the other bank.
Or did i miss the point?
Refer to the following knowledgebase article:
http://www.keil.com/support/docs/1615.htm
and make sure that the g_UnitDesignation array and the Log_GetLogText function are located in the same bank.
Second, return outputString from your Log_GetLogText function is a BAD idea. The outputString is not in scope outside that function.
If you have some control over the hardware design, using xbanking (http://www.keil.com/support/man/docs/c51/c51_ap_xbanking.htm) may work better for you.
Jon
Then consider a change of processor.
You are fighting a fundamental limitation of the 8051 architecture - is that a battle worth fighting?
Could your time be better spent in switching to an architecture which does not have this fundamental limitation?