AnsweredAssumed Answered

array variable has array size + 1 in memory!

Question asked by johnmurray on Oct 6, 2011
Latest reply on Oct 6, 2011 by dsmtoday

I noticed this problem before with a SPI test app but it did not cause me any problems as I could just ignore the extra indexable memory location.


Basically I am declaring an array of size x but when I look at it in Data Memory and the array has a size of x + 1


#define TAPS1 1

#define TAPS2 2

#define TAPS3 3


extern float pm ch_ce2_F0_A[TAPS2];

extern float pm ch_ce2_F0_B[TAPS2+1];

extern float pm ch_ce2_F1_A[TAPS1];

extern float pm ch_ce2_F1_B[TAPS1+1];

extern float pm ch_ce2_F2_A[TAPS2];

extern float pm ch_ce2_F2_B[TAPS2+1];

extern float pm ch_ce2_F3_A[TAPS2];

extern float pm ch_ce2_F3_B[TAPS2+1];

extern float pm ch_ce2_F4_A[TAPS2];

extern float pm ch_ce2_F4_B[TAPS2+1];

extern float pm ch_ce2_F5_A[TAPS1];

extern float pm ch_ce2_F5_B[TAPS1+1];

extern float pm ch_ce2_Fosc;

extern float pm ch_ce2_k;

extern float pm ch_ce2_depth;

extern float pm ch_ce2_G;


So ch_ce2_F2_B should have 3 values but it has 4 values in the memory map!!!!

Same with ch_ce2_F3_B, ch_ce2_F3_B


I have noticed this before in other test apps but it never caused a problem before.

Now I am doing a memcpy over that block of memory, but because two of the arrays have extra space allocated, the memory does not align correctly!

What’s going on!


I tried changing the arrays to sid in dm instead of pm but this did not have any effect.