Hello.
I'm trying to allocate a structure variable in GSRAM using a cmd file.
Here is the definition of the structure:
typedef struct{
float ValueV[41];
float ValueI[31];
float ValuePH_30[42];
float V_Boundary110V[4];
float I_Boundary1A[3];
unsigned int CALIBRATE_ADC_0[6];
unsigned int CALIBRATE_ADC_1[6];
}CALIBRATE_VALUE;
I roughly calculated the size of this structure to be:
- 121 floats = 121 * 4 bytes = 484 bytes
- 12 ints = 12 * 2 bytes = 24 bytes
Therefore, the total size of the structure is 484 + 24 = 508 bytes.
Based on this calculation, I declared 508 bytes of memory in the CMD file as follows, but I got a memory size error:
RAMGS_USER_DATA : origin = 0x00C020, length = 0x0000FE
Since 1 word of memory is 16 bits, 508 bytes = 254 words = 0x FE should be correct.
However, in order for this memory allocation to work without errors, it needs to be declared as follows:
RAMGS_USER_DATA : origin = 0x00C020, length = 0x00011E
Even if memory padding is done to align the memory word size, I don't think 286 words (11E) are needed.
Is there a rule about memory allocation that I'm not aware of?
I'll wait for your opinion.