Hi,
I am using the uVision2 v2.06
C51 - 6.02 A51 - 6.02 BL51 - 4.02 LIB51 - 4.12 OH51 - 2.5 S8051.DLL - 2.02 DP51.DLL - 2.02
Targeting an 8051.
When I follow the instructions here: http://www.keil.com/support/docs/130.htm
The segment is located at the correct position in memory, but when I initialise the data as in the example, it also increases my program memory size. I'm moving the data to this segment specifically to avoid the loss of code space! Should this work or is this a feature that appears in a later version of the tools?
Thanks, Brett
So...I did discover the "XCROM" directive:
http://www.keil.com/support/man/docs/c51/c51_xcrom.htm
So my code is:
#pragma XCROM const STRING_STRUCT xdata Strings = {stuff};
However, the compiler is reporting "unknown #pragma"!!
You have basically four options for global variables.
Don't initialize them at all (requires extra work).
Just don't assign a value. Then the startup code will zero-assign them.
Give them a specific value. Then the compiler _must_ store a copy of the data in the code space to allow copying the value from code space into your variable.
Create a const variable in the code segment. Then you get an initialized variable that don't consume space in both code and ram. But you can't change the value.
The link you have found seem to specify how you can use special mappings in some processor variants so that you can have the data in the flash (code segment) but be visible as xdata.
With a standard processor, that doesn't have this "magic mapping" support, you will have to declare the const variable as code instead for xdata. This will affect all pointers to your variable since it will not be fully transparent to the rest of the application.
You are using quite an old version - are you sure it supports this feature?