Other Parts Discussed in Thread: MSP430G2553
I want to use a 128 bytes data table in CCS for an MSP device that has 64 bytes info sections.
Therefore i want to spread it out between infoC and infoB
currently i use the code below which is bad for two reasons:
- I am accessing data[] for higher indices than it was declared (knowing that data2 will be behind it)
- I need the first line in main to convince the compiler to also put data2 in the memory, otherwise it will assume I am stupid and need some help deleting unused variables.
Is there a way to do this while:
- keeping the data in the info sections (I want to keep memory usage as small as possible)
- losing the dummy read (first line of main() ) to trick the compiler.
- keeping the data in the program (I don't want to do a separate data upload step in CCS each time)
#pragma location=0x1080 // second part of data table, stored at address of info segment B
const unsigned char data2[64] = {34,39,46,52,59,67,74,82,90,97,104,111,116,121,124,127,127,127,124,121,116,111,104,97,90,82,74,67,59,52,46,39,34,29,24,20,17,13,11,8,6,5,3,2,1,0,0,0,0,0,0,0,1,2,3,5,6,8,11,13,17,20,24,29
#pragma location=0x1040 // first part of data table, stored at address of info segment C
const unsigned char data[64] = {74,81,87,94,102,109,116,124,132,139,147,155,163,170,178,185,192,199,205,212,218,223,229,233,238,242,245,248,251,253,254,255,255,255,254,253,251,248,245,242,238,233,229,223,218,212,205,199,192,185,178,170,163,155,147,139,132,124,116,109,102,94,87,81};
int main(int argc, char *argv[])
{
int T, dummy;
dummy=data2[0]; // (:) needed to keep compiler from throwing it out :-)
T=127;
while (T) {
somefunction(data[T]);
T--;
}
}