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.

Compiler/TMS320F28379S: Is there an automatic way to have a string constant stored in flash such that two characters are stored in each word?

Part Number: TMS320F28379S


Tool/software: TI C/C++ Compiler

Hello all,

I'm trying to figure out how to store a string constant into flash with minimal overhead, (yes flash is a restricted resource). I know I can brute force it by "building" the word array manually, but this won't work in my case. The string constant is passed in as a macro definition at compile time, effectively giving the situation:

const unsigned int Table[16] = MACRO_SUPPLIED_NAME;

Where MACRO_SUPPLIED_NAME is a 32-byte long string constant specified in the CCS project as a command line -D option.

I know that TI redefines a byte to be 16 bits, so I suspect that there is now easy way to get the compiler to store each character of the array as 8-bits. Please tell me there is a way.

Regards,

S

  • Unfortunately, there is no straightforward solution.  I'm not aware of any published solution by TI.  Here is a rough proposal, untested by anyone, for you to consider.

    Create the string in hand-coded assembly with the directive .pstring.  Pass the string from the command line with the build option --asm_define.  Read about both of those in the C2000 assembly tools manual.  

    In your C code, operate on these packed strings with the __byte intrinsic.  Read about that in the article Byte Accesses with the C28x CPU.  I suggest you write two routines in C.  One unpacks the strings into 16-bit wide chars.  Then you can do normal string operations on them with the usual string functions like strcpy, strcat, and so on.  The other packs the strings back into the 8-bit wide representation.

    Thanks and regards,

    -George