This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am trying to use shared RAM for message passing between the cores on the F28M35x. Specifically in this case, I am passing messages from the M3 to the C28 and using variables allocated to the MTOCRAM section.
I have multiple variables that are being passed. However, it appears that in actual usage, the allocation order is different on the two cores, even though they are declared in the same order on both cores. The result is that variableA gets put where I thought variableB would be, and vice versa. So, is there a defined way that memory is mapped, or is the order undefined?
C28 Code:
#pragma DATA_SECTION("MtoC") Int32 SrCommand = 0; #pragma DATA_SECTION("MtoC") Int32 SrCommandValue = 0;
C28 Memory Map:
0003fc00 ff0 (0003fc00) _SrCommandValue 0003fc02 ff0 (0003fc00) _SrCommand
M3 Code:
#pragma DATA_SECTION("MtoC") Int32 SrCommand = 0; #pragma DATA_SECTION("MtoC") Int32 SrCommandValue = 0;
M3 Memory Map:
2007f800 SrCommand 2007f804 SrCommandValue
Note how both are declared in the same order, but the C28 allocated them in reverse order in the MtoCRAM section.
Am I doing something incorrect? Is there no expectation to how the variables are allocated based on declaration order?
Hi Michael,
I don't think there is any rule for compiler to follow the order in which they are defined while allocating in memory. If you want to make sure variable on C28x and M3 are placed at same location in memory, I would suggest to make a specific section in .cmd file for each variable on both the cores and then allocate the variable using #pragma, like below.
#pragma DATA_SECTION(SrCommand,"MtoC-1");
#pragma DATA_SECTION(SrCommandValue,"MtoC-2");
Hope this was helpful.
Regards,
Vivek Singh
Hi Vivek,
Thanks for confirming that. Does that mean that I would have to split up the definition of the MTOCRAM section in the linker file? Or is there a way to link to a memory address?
For example, the MTOCRAM is defined as:
MTOCRAM : origin = 0x03FC00, length = 0x000380 /* M3 to C28 Message RAM */
Do I have to split it up to:
MTOCRAM1 : origin = 0x03FC00, length = 0x000002 /* M3 to C28 Message RAM */ MTOCRAM2 : origin = 0x03FC02, length = 0x00037D /* M3 to C28 Message RAM */
Or is there some other way to do the linking as you suggest?
Thanks
Michael,
You've got it right. The easiest thing to do is split the memory definition up as you showed (for example), and then use the DATA_SECTION pragma to force the items of interest to the memory location you want.
Regards,
David