Hi,
I need store constant configuration data (sample below) to the flash memory starting address as 0x00080000.
Example :
Config string : 8bytes : char data : 0x00080000 (start address)
Config ID : 2bytes : int data : 0x00080008
unit_type : 1byte : int data : 0x0008000A
sensor_type : 2byte : int data : 0x0008000B
filer_const : 4byte : floatdata : 0x0008000C
I created a .config data section in the linker directive which starts at 0x00080000.
I used the #pragmas to do this task as below in one of the source file.
#pragma DATA_SECTION (CFG_STR , ".config" )
const int8 CFG_STR[8] = {'1','1','3','8','V','A','0','1'};
#pragma DATA_SECTION (CFG_ID , ".config" )
const uint16 CFG_ID = 0xABCD;
#pragma DATA_SECTION (UNIT_TYPE , ".config" )
const uint8 UNIT_TYPE = 0x00;
#pragma DATA_SECTION (SENSOR_TYPE , ".config" )
const uint16 SENSOR_TYPE=0x02;
#pragma DATA_SECTION (FILTER_COEFF , ".config" )
const float32 FILTER_COEFF = 6.5;
I can see this data in flash but not in the required address as mentioned above. I see that memory address allocation
of these variables is in the order of definition i.e top to bottom.( CFG_STR.. UNIT_TYPE .. FILTER_COEFF )
1) Does it always allocates memory in the order of declaraion in source file ? What is the gurantee ?
Ex :For the above sample code, the memory address allocation and order is as below observed in debugger.
(CFG_STR = 0x00080000 , CFG_ID = 0x00080008, UNIT_TYPE=0x0008000A, SENSOR_TYPE= 0x0008000C, FILTER_COEFF = 0x00080010)
Is there any chance that FILTER_COEFF allocated immediately after CFG_STR instead of CFG_ID ? If so how to handle it ?
2) In the debugger, i see that there are some holes in between these variables memory allocation.
Is there any way to suppress this padding ? Ex : SENSOR_TYPE requires 2 bytes, after that 2 bytes are filled with 0x00.
[ i found variable attributes (gcc extensions) for this purpose and not working as i expect]
3) Actual configuration data to be stored as per my requirement is around 20K. I tried with strucure to do this job.
I need to do the explict initialization for that too. Any other suggestion apart from the above method ?
Processor : TMS570LS20216 (Cortex R4), Code Composer Studio : 4.2.0.10018, TMS470 C/C++ CODE GENERATION TOOLS 4.6.3