DSPRelated.com
Forums

Allocating initialized data in CODE_SECTION

Started by tatanka01b September 12, 2008
Hi... New here and to the CCS world in general.

I am working on a project to convert some MSP430 assembly code to "C"
using Code Composer. The structure of the system requires me to have
a 2-byte version number at the very beginning of the FLASH image --
something that is very easy to do in assembly:

org 8000h
dw 0214h ; version 2.20
org 8002h
code goes here, etc

So far, I've been unable to figure out how to do this in C. I've
successfully moved where the code starts to 8002, but I can't seem to
get the compiler to put initialized data in the code section.

If I do this:

#pragma CODE_SECTION (REVISION, ".vers");
BYTE REVISION[] = {2,20};

I get a warning "pragma CODE_SECTION can only be applied to a function
definition"

And if I do this:
#pragma DATA_SECTION (REVISION, ".vers");
BYTE REVISION[] = {2,20};

The project builds with no warnings/errors, but the linker doesn't
actually output the {2,20} data.

(.vers is defined as a 2-byte section @ 8000h)

Any ideas? I can always add the version in at the HEX file level, but
I'd like to avoid the extra step.