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.
Tool/software: TI C/C++ Compiler
Hi,
I have a custom cmd file which defines the load and run locations for some parameters that i would like to calibrate. the behavior and setup is very similar to the other thread, which is locked for nowCLA Warning - C2000 microcontrollers forum - C2000™︎ microcontrollers - TI E2E support forums
the only difference is that i'm on a 28335 and I'm not using CLA.
after a few trys, i found that statements like
#pragma DATA_SECTION(aDataName, "aDataSec")
int aDataName = 1234;
in a custom declared data_section would NOT be considered 'initialized data' thus the warning and wrong behavior.
i was able to get around by adding a const keyword:
#pragma DATA_SECTION(aDataName, "aDataSec")
const int aDataName = 1234;
then the warning goes away, the data is put in the right flash location.
but this aDataName var isn't really a constant. i'm tuning it in the RUN location, which is ram. I don't change it in the code but with memory write directly so i would rather not to declare it const.
Can anyone from the compiler team to look into this issue? why a standard C statement with initial value declaration is not honored by the compiler? is this a bug in the compiler? any reference document?
I see a few similar posts in the forum but i don't think any one of them got a straight answer out yet.
thanks.
regards
gzhang
The following discussion pertains to static or global variables, and not variables that are local to a function.
When you write something like ...
int normal_var = 10;
The compiler makes entries in two different sections. It creates space in a read-write section (normally .ebss) for the variable normal_var. And it arranges a record in the .cinit section that, when processed at boot time, copies the value 10 to normal_var.
Contrast that with ...
const int const_var = 20;
In this case, the compiler only makes one entry in a read-only section (normally .econst). The entry both creates and initializes the variable.
I find this part confusing ...
Leong said:but this aDataName var isn't really a constant. i'm tuning it in the RUN location, which is ram. I don't change it in the code but with memory write directly so i would rather not to declare it const.
... so I'm not sure what you should do. But I am confident you can work that out by using this explanation on the difference between a non-const initialized variable and a const initialized variable.
Thanks and regards,
-George