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.
Hi,
I am migrating from IAR to Code composer, at the moment I am using the MSP430F2013 controller.
In IAR I had the following code:
#define CHANNEL_DEFAULT 3
#define CHANNEL_PTR_ADDR 0x1001
const unsigned char ChannelAddr @ CHANNEL_PTR_ADDR = CHANNEL_DEFAULT;
After building the value 3 was then located at address 0x1001 and in my code I could then read out the value directly. This helps to eliminate init code first time the project runs. Alternative I had to check to see if the memory space was blank and then write the default values (I have more constants allocated) so this way helps eliminate code.
My question is, how do I do this in Code Composer, the code above does not compile..
tanks
Thomas Langholen
Hi Thomas,
have a look at par. 'IAR 2.x/3.x/4.x to CCE C-Migration in MSP-FET430 Flash Emulation Tool (FET) (for Use With Code Composer Essentials for MSP430 Version 3.1)' Users Guide (http://www.ti.com/litv/pdf/slau157i ; it's the same with CCS V4.0).
There are some posts in the forum about this topic too.
Rgds
G**kbuster
Thomas,
if you want to place your constant data at a certain location, in CCS you would want to use a #pragma DATA_SECTION(symbol, "section name") statement which allows placing data into named segments (as defined in the linker command file). The below example assumes a 2xx-type device and locates 3 constants into the INFOD Flash memory region which starts at address 0x1000. If you need tighter control or guarantee placement at specific locations, you could create a dedicated memory segment for each variable.
#pragma DATA_SECTION(variable, ".infoD")
const unsigned char variable = 20;
#pragma DATA_SECTION(anotherVariable, ".infoD")
const unsigned char anotherVariable = 30;
#pragma DATA_SECTION(yetAnotherVariable, ".infoD")
const unsigned char yetAnotherVariable = 40;
Make sure there are no spelling mistakes or mismatches between the named segment used in the #pragma vs. the linker command file. Otherwise, data will get located into the default segment, which conveniently starts at 0x0000, most certainly getting you into trouble. It's a good idea to closely watch the linker output for any warnings regarding this.
Regards,
Andreas