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.
Hello!
I have faced a strange problem in CCS 5.2 with memory allocation using #pragma DATA_SECTION.
The problem is that two variables of different type and size are allocated with a gap of 1 memory page between them in solid memory area.
When I was using CCS 3.3 everything was ok. And now, when I have ported my project I have a problem.
Here is memory area definition in my .cmd file:
MEMORY
{
...
PAGE 1:
TEST_MEM: origin = 0x200000, length = 0x1000
...
}
And here is section definition in .cmd file
SECTIONS
{
...
test_mem :> TEST_MEM, PAGE = 1
...
}
Then I defined 2 variables in .c file and placed them into a section test_mem:
unsigned int var1=0;
int var2[0x100];
#pragma DATA_SECTION(var1,"test_mem")
#pragma DATA_SECTION(var2,"test_mem")
The compilation goes without errors but then I look at the .map file and see:
00200000 _var1
00200040 _var2
There is a gap of 0x40 words between variables. Variables var1 and var2 are the only variables in this memory area. What can I do to place them in memory one by another(without gap)?
Try defining var2 first.
Since var2 is an array, it might be aligning on a data page for some optimization reason.
What is the problem though?
The problem is that I need var1 first in memory and var2 next but without a gap. As I've mentioned above everything was good in ccs 3.3 and now I have a problem. All optimisation features are off.
Though it allocated to one after another without gap, it is not safe to assume it will happen always for auto allocated memory. It can change with more variables and other conditions.
There could be many methods to overcome your special requirement of 'contiguous memory address'. Try defining structure with var1 and var2 as members, so that always both of them take contiguous memory.
Hope it helps
I tried structure earlier and it helps but I don't understand what has changed since ccs 3.3. This memory section contains only 2 variables. I want this variables to be placed in memory in a certain order, one by another. And compiler makes something for me that I didn't ask. Maybe there is some compiler option that I forgot to use?
Which controller are you using?
TEST_MEM: origin = 0x200000, length = 0x101
if those are the only variables in the region. :)
I'm using F28335. I've tried your example and got an error:"error #10099-D: program will not fit into available memory. run placement with aligment/blocking fails for section "test_mem" size 0x140 page 1" What does this option "aligment/blocking" mean? How can I switch it off? I think the problem is in this option.