Hello,
For my application, I need to know addresses of memory segments defined at link time. I manage to do it for a segment call MY_ZEROPAGE, DEFAULT_ROM and for SSTACK.
But when I try to get the start address of the DEFAULT_RAM, I get the message :
WARNING L4024: No information available for segment 'DEFAULT_RAM'
I have carefully read the help on that topic, but don't find where I am wrong.
Here is My prm file (generated by ProcessorExpert) :
NAMESENDSECTIONS Z_RAM = READ_WRITE 0x0080 TO 0x00FF; RAM = READ_WRITE 0x0100 TO 0x017F; MY_STACK = READ_WRITE 0x0180 TO 0x027F; ROM = READ_ONLY 0xE000 TO 0xFD9F FILL 0x82; CONST_DATA = READ_ONLY 0xFDA0 TO 0xFDB9 FILL 0x82;ENDPLACEMENT CONST_ROM_DATA INTO CONST_DATA; /* Added manually */ DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM; DEFAULT_RAM INTO RAM; _DATA_ZEROPAGE, /* zero page variables */ MY_ZEROPAGE INTO Z_RAM; SSTACK INTO MY_STACK; /* Added manually */ENDINIT _EntryPoint /* The entry point of the application. This function is generated into the CPU module. */STACKTOP 0x027F /* Top address of the system stack. Value can be changed on the "Build options" tab */
and below, the source code :
extern char __SEG_START_MY_ZEROPAGE[];extern char __SEG_END_SSTACK[];extern char __SEG_START_DEFAULT_RAM[];void Function(void){ unsigned char * pucZRam; /* Step 1 : write all zeros */ for (pucZRam = (unsigned char *) __SEG_START_MY_ZEROPAGE; pucZRam < (unsigned char *) __SEG_START_DEFAULT_RAM; pucZRam++) { *pucZRam = 0; } }
The map file confirms that ther is an issue with DEFAULT_RAM, since address value is 0 :
...
- LABELS:
__SEG_START_MY_ZEROPAGE 80 0 0 1
__SEG_START_DEFAULT_RAM 0 0 0 1
...
Help is welcome.
Thanks
Solved! Go to Solution.
Hello
Per default the compiler will use following predefined section names to allocate variables:
.data : Contains the initialized global variables (also called DEFAULT_RAM).
e.g. int a = 1, b= 2;
.bss : Contains the static un-initialized global variables.
e.g. static int c, d ;
.common : Contains the un-initialized global variables.
e.g. int e, f;
So if you only have un-initialized global variables in your application DEFAULT_RAM section will not be used. You can then retrieve start address for RAM using _SEG_START___DOT__bss.
If you really want to allocate a variable in DEFAULT_RAM section, do the following:
#pragma DATA_SEG .data#pragma DATA_SEG DEFAULTint var @".data";
CrasyCat
Hello
In your application I assume you do not have anything allocated in section DEFAULT_RAM.
So the section does not exist and you cannot retrieve its start address or size.
CrasyCat
Ok, I think that I understand what you mean.
Actually, I don't have explicitelly allocated any variables in DEFAULT_RAM segment.
In my current PRM file, the DEFAULT_RAM segment belongs to the RAM section, from 0x100 to 0x17F.
Thanks to the map file, I see that I have some variables placed by default in this memory area. But, they don't belong to DEFAULT_RAM, if I am right.
- VARIABLES: uiCurrentStackPointer 100 2 2 2 .bss bTestRamPassed 107 1 1 2 .common
How can I explicitely allocate variables into the DEFAULT_RAM sections?
I tried to use the pragma directive, but without success :
#pragma DATA_SEG DEFAULT
I am able to get the start address of bss section, thank to __SEG_START___DOT__bss.
But I am not sure if this is the right way to get the start and and addresses of DEFAULT_RAM.
Hello
Per default the compiler will use following predefined section names to allocate variables:
.data : Contains the initialized global variables (also called DEFAULT_RAM).
e.g. int a = 1, b= 2;
.bss : Contains the static un-initialized global variables.
e.g. static int c, d ;
.common : Contains the un-initialized global variables.
e.g. int e, f;
So if you only have un-initialized global variables in your application DEFAULT_RAM section will not be used. You can then retrieve start address for RAM using _SEG_START___DOT__bss.
If you really want to allocate a variable in DEFAULT_RAM section, do the following:
#pragma DATA_SEG .data#pragma DATA_SEG DEFAULTint var @".data";
CrasyCat
Thank you for the explanations, things get clear.
This topic is closed for me.