hello,how to increase the size of an array?
uint8_t[]={1,2,3,...................}; arduino size of array is too large
uint8_t test_array[8192] PROGMEM = {0};
hello,how to increase the size of an array?
uint8_t[]={1,2,3,...................}; arduino size of array is too large
uint8_t test_array[8192] PROGMEM = {0};
Omnimusha:
How do you increase the size of an array?
// The number of initializers in the curly braces determines the array size when no value
// is specified in the square brackets.
uint8_t name1[]={1,2,3,4,5,6,7};
// If a value is specified in the square brackets it will determine the array size
// even is initializers are specified in curly braces
uint8_t name2[92];
uint8_t name3[27]={1,2,3,4,5,6,7};
Once the array is declared you can't change the size.
johnwasser:
Omnimusha:
How do you increase the size of an array?// The number of initializers in the curly braces determines the array size when no value
// is specified in the square brackets.
uint8_t name1[]={1,2,3,4,5,6,7};
// If a value is specified in the square brackets it will determine the array size
// even is initializers are specified in curly braces
uint8_t name2[92];
uint8_t name3[27]={1,2,3,4,5,6,7};
Once the array is declared you can't change the size.
You did not understand me. I mean when the array size is greater than 8192, the compiler gives an error, "sketch_mar03c:73: error: too many initializers for 'uint8_t [8192]'
".
uint8_t test_array[] PROGMEM = {
22,22,22,22,21,21,21,21,20,20,18,18,18,18,18,18,19,19,19,18,18,17,17,17,21,21,21,21,21,21,21,21,20,20,20,20,20,20,20,20,28,26,23,22,22,21,19,16,25,20,19,22,23,22,27,32,29,28,30,30,29,29,29,28,23,21,21,21,23,23,24,24,26,26,28,28,29,29,29,26,21,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,18,22,20,20,20,20,20,22,22,23,21,19,17,20,22,25,27,25,25,25,25,25,25,25,25,22,23,26,26,26,25,25,26,31,32,31,30,28,28,26,26,26,26,25,25,22,22,21,21,25,25,25,25,25,25,25,25,22,22,21,20,20,21,22,22,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,23,21,19,18,17,18,19,19,20,19,19,18,17,17,17,16,17,16,15,16,18,20,20,21,23,24,24,24,24,24,24,24,22,25,27,27,25,22,20,19,22,26,45,34,14,30,41,28,25,28,28,24,22,23,22,18,27,26,26,26,26,26,26,26,18,24,29,29,25,19,16,17,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,26,26,26,26,27,27,29,29,29,29,30,30,30,29,30,25,21,16,13,16,26,32,29,29,29,29,30,30,30,30,30,30,30,30,29,29,28,28,30,12,10,26,28,16,17,35,24,26,26,26,26,26,26,26,36,33,30,30,33,33,31,25,29,28,28,28,27,27,27,27,29,27,23,22,21,20,21,23,19,19,19,19,18,18,18,18,17,17,17,17,
24,22,22,22,22,21,21,21,20,18,18,18,18,17,18,17,16,16,16,15,14,13,13,13,15,15,15,15,15,15,15,15,31,31,31,31,31,31,31,31,30,27,25,27,31,33,31,29,38,31,29,34,34,30,29,34,36,37,37,37,36,35,37,34,19,18,18,19,19,20,20,22,27,27,29,29,30,30,30,29,23,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,22,22,22,22,22,22,22,21,18,18,18,18,18,18,19,19,25,23,22,22,26,29,33,36,37,37,37,37,37,37,37,37,41,39,37,38,41,43,43,43,42,44,44,45,43,42,39,37,38,37,38,37,35,33,31,28,20,20,20,20,20,20,20,18,26,23,24,21,21,22,23,24,21,21,21,21,21,21,21,21,21,21,21,21,21,19,21,21,21,21,21,21,21,21,21,21,21,21,20,20,21,23,25,25,17,16,17,16,15,14,14,14,13,17,21,21,19,15,13,14,20,21,21,21,21,21,21,21,22,20,20,22,24,25,24,22,26,16,15,32,25,16,30,17,25,23,23,25,26,27,33,40,22,22,22,22,22,22,22,22,20,22,24,24,24,26,31,36,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,28,28,28,28,28,28,30,30,31,31,31,31,33,33,33,31,18,23,31,34,32,29,29,29,23,23,23,23,24,24,24,24,24,24,24,24,24,23,21,21,20,32,29,16,16,28,23,13,29,32,32,30,32,30,32,30,21,20,19,22,25,27,27,25,23,23,23,23,21,21,21,20,25,20,19,21,22,21,22,24,18,18,18,16,16,16,16,15,15,15,15,15,
26,25,25,23,23,23,22,22,19,19,19,18,18,17,18,17,16,16,15,14,13,13,12,12,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,7,7,12,24,39,51,
13,19,25,22,17,22,41,56,47,48,51,51,46,36,31,33,38,45,77,96,110,117,108,115,104,94,103,104,85,86,96,86,107,111,115,113,112,115,118,119,125,112,109,106,95,102,121,132,47,46,48,54,58,56,49,41,42,40,29,39,47,41,38,23,22,23,18,22,38,39,30,29,13,15,19,26,32,36,37,38,23,48,62,65,76,80,79,82,74,74,75,75,77,77,78,77,77,76,77,78,79,80,81,81,84,85,84,82,79,78,79,83,90,91,92,91,91,92,90,90,88,107,130,145,152,153,157,159,145,142,145,146,150,149,149,146,134,134,137,140,144,143,142,138,155,151,148,149,151,154,152,150,156,152,145,144,146,152,153,152,150,158,159,165,152,152,146,150,154,148,146,145,143,136,134,134,133,118,102,93,96,99,95,87,70,69,68,68,66,66,65,65,69,71,71,70,71,72,73,74,51,66,80,64,58,60,57,78,60,56,58,55,67,47,68,150,151,247,255,244,229,255,228,242,255,226,229,240,236,255,251,253,252,254,255,255,255,254,250,248,249,248,249,250,251,252,253,253,247,252,251,248,253,255,255,255,255,252,144,159,232,226,227,230,230,237,251,255,255,251,255,255,255,255,250,242,232,242,253,252,250,250,250,250,250,250,250,250,252,248,247,245,243,241,239,237,246,245,247,247,247,248,249,250,255,255,254,254,255,255,255,255,255,255,255,255,252,249,250,247,253,255,255,249,190,162,175,196,180,182,185,191,197,200,201,201,211,187,192,188,189,122,104,111,123,109,108,114,145,144,149,150,137,143,145,37,34,38,24,39,21,34,58,77,77,66,55,51,17,14,15,20,19,16,23,35,22,20,20,19,
23,38,48,40,31,32,37,38,31,40,64,97,123,131,130,129,75,68,80,79,76,67,42,38,48,55,85,88,51,40,52,45,36,43,47,46,49,57,62,61,52,43,49,50,41,64,111,136,112,83,51,45,66,92,106,109,103,129,118,91,54,31,47,42,41,39,32,34,46,45,34,32,19,15,11,10,11,14,16,17,13,22,21,28,45,49,46,48,70,70,71,71,72,72,74,72,73,72,72,73,73,74,75,75,70,71,73,71,69,69,72,75,79,81,82,82,82,84,83,82,80,88,96,96,92,84,80,77,84,85,92,101,113,120,124,124,122,104,84,75,85,104,124,134,78,78,80,88,101,111,115,115,103,99,97,97,99,101,98,94,102,140,159,149,92,82,95,129,123,116,114,116,116,110,105,101,105,100,91,78,74,76,76,74,72,70,69,69,67,67,66,66,68,68,64,56,47,41,41,42,47,29,19,8,19,22,6,15,8,10,13,29,11,34,23,14,145,146,244,255,255,246,255,253,238,255,249,252,251,255,238,238,245,247,247,247,249,250,251,252,250,251,251,251,252,253,253,253,255,249,242,250,255,251,249,253,255,151,157,254,241,254,255,252,248,250,250,247,242,239,240,243,249,242,245,253,245,247,250,249,254,254,254,254,254,254,254,254,250,250,250,252,253,253,252,251,252,252,255,254,253,252,253,253,248,246,244,243,244,245,246,247,251,241,245,252,251,254,255,255,255,246,186,189,190,201,199,193,205,205,204,203,203,203,203,198,199,204,200,188,197,196,191,186,157,132,134,127,137,126,141,136,128,131,140,136,124,60,90,49,65,61,57,51,42,38,45,55,30,20,15,15,10,6,13,27,38,36,36,35,
35,42,42,40,54,75,83,75,87,73,64,70,79,75,66,59,53,48,59,56,54,57,51,63,51,45,68,77,54,58,72,60,59,58,53,45,48,56,60,58,71,52,54,59,47,50,59,51,59,55,50,50,52,54,52,50,46,108,116,98,84,87,89,43,35,42,42,38,41,37,35,44,37,26,14,5,3,5,10,14,24,16,8,18,43,51,46,50,52,53,53,54,54,56,56,56,54,53,53,52,52,52,52,53,57,60,63,65,65,68,72,78,79,80,82,82,83,82,83,82,77,76,75,75,77,83,89,93,88,82,82,82,82,80,75,70,75,70,68,75,84,87,80,72,83,77,73,74,80,82,82,80,93,95,100,105,107,101,90,79,89,91,78,90,79,91,78,77,77,68,63,64,64,58,50,43,32,40,47,39,31,29,29,27,14,13,11,11,10,10,10,10,10,10,17,17,9,8,7,6,6,4,8,4,9,21,9,14,26,21,17,7,25,8,8,2
};
I mean when the array size is greater than 8192, the compiler gives an error, "sketch_mar03c:73: error: too many initializers for 'uint8_t [8192]'
Then don't provide more than 8192 initializers. What, exactly, is that array to be used for?
uint8_t test_array[] = {1,2,3........................................................8192+1}; 8192+1>size array ,,"sketch_mar03c:73: error: too many initializers for 'uint8_t [8192]'
".
: how to increase the size of an array?
Maybe its a compiler limit?
If not,maybe you need a part with more SRAM for an array that can have its contents changed, or put it in PROGMEM if the values will not change.
Atmega1284 has 16K SRAM, the most of all the 168/328/1280/2560 AVRs, and 128K flash.
Maybe its a compiler limit?
if the size limit of the array.
one of the solutions would be to divide the number of items, and put them
the other party in another array
but ........ I can change the array size limit?
I don't know, need one of the software guys to jump in & confirm that.
It would help if you said which Arduino you are using and post all your code (inside code tags using the # icon).
Pete
I was under the impression that the limit for avr-gcc was 32kB arrays (or 32k elements, whichever is smaller).
I just tried and had no problem compiling a program with an array of 8193 elements. I did try declaring the array as 8192 bytes and adding an extra and got the error message you reported. It looks like you have given too many initialisers as the error suggests (you specified more elements than fit in the array length you specified).
here in example
That array has well over 32768 elements and it seems that the compiler does not permit an array to have more than 32767 elements. You can't change the array size limit. You will have to figure out a way to break the array up into several pieces.
It would help if we knew why you were using such a large array.
Pete