Pages: [1]   Go Down
Author Topic: largest array in progmem?  (Read 1022 times)
0 Members and 1 Guest are viewing this topic.
Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
prog_uint8_t text [] PROGMEM = {};

I don't think i'm really on form today. Can someone help what is the maximum size possible for this array. assuming it had some data in it. Is it 640 bytes? I'm using a mega and i'd like to create a 1920 byte array but i cant.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The size of the array is defined by the number of initializers. How many are you providing? None, zip, zilch, nada...
Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry i sort of assumed by answering the question you would already have filled that in in your mind. Yes that code means nothing it was their to serve as a start point for the question. i doesn't matter ive decided split the array up now. I don't think you can initialise it to 1920 bytes. sorry if i was unclear as i said not on top form today.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't think you can initialise it to 1920 bytes. sorry if i was unclear as i said not on top form today.
But, you can. I'm not aware of any limits (other than physically fitting onto flash memory) on a progmem array size.

On a mega, a 1920 byte array should be trivial.

Your real code?
Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well the real code (while i can post it aster a bit of pruning) is getting very unwieldy.

as an example.
Code:
prog_uint8_t Colour_Texture_1 [192] PROGMEM = {140,137,201,153,152,213,130,133,194,134,139,198,143,148,213,142,142,205,135,134,197,115,119,182,142,140,202,146,143,203,132,135,195,138,142,200,149,154,215,136,137,199,125,126,186,111,112,174,135,134,197,130,126,183,122,116,171,128,125,183,150,151,213,143,141,203,135,128,187,117,116,176,126,126,190,131,134,196,123,116,171,130,125,181,138,141,204,142,140,205,143,137,198,138,139,203,126,125,186,134,136,196,127,119,175,128,121,177,136,138,198,136,138,206,134,129,190,139,138,201,121,116,173,126,122,178,129,123,181,97,79,123,128,124,183,125,126,189,128,121,179,126,125,188,111,102,156,118,110,163,107,91,136,90,66,106,126,118,173,117,112,167,121,114,169,120,119,184,109,98,152,120,115,170,99,81,125,97,78,121,120,112,169,117,113,173,115,107,163,116,116,181};

that works fine

Code:
prog_uint8_t long_sea_1 [1920] PROGMEM = {0,0,0,0,0,0,0,0,0,0,0,0,10,11,20,0,14,161,0,22,249,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,4,21,189,0,23,251,0,24,255,0,23,254,0,0,0,0,0,0,0,0,0,0,0,4,27,47,255,0,23,255,0,24,255,0,23,254,0,0,0,0,0,0,0,0,0,6,7,36,62,78,242,7,28,230,0,21,240,0,24,255,0,0,0,0,0,0,0,0,0,25,26,34,106,121,255,19,20,23,0,14,171,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,0,1,43,0,0,0,0,6,76,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,91,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,27,0,22,245,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,17,196,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,23,28,76,3,26,249,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,32,44,159,0,22,236,0,21,237,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,138,149,249,24,26,44,0,9,120,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,14,24,128,17,20,43,0,6,77,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,18,213,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,19,213,0,23,249,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,37,43,101,2,24,248,0,24,255,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,87,97,181,17,38,248,0,22,250,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,70,77,144,89,97,182,0,0,52,0,21,233,0,0,0,0,0,0,0,0,0,0,0,0,33,36,57,15,16,28,0,3,38,0,20,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,41,0,21,236,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,210,0,23,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,152,0,22,243,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,0,22,246,0,24,255,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,80,88,166,11,30,232,0,19,227,0,23,254,0,0,0,0,0,0,0,0,0,8,9,14,138,147,230,30,34,69,0,3,44,0,19,221,0,0,0,0,0,0,0,0,0,0,1,1,61,65,113,15,17,38,0,0,0,0,16,182,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,4,57,0,20,229,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,219,0,23,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,18,211,0,23,246,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,7,148,0,21,248,0,22,244,0,23,253,0,0,0,0,0,0,0,0,0,0,0,0,69,86,255,21,33,164,0,10,116,0,19,218,0,0,0,0,0,0,0,0,0,0,0,13,99,112,243,11,11,11,0,0,7,0,18,197,0,0,0,0,0,0,0,0,0,0,0,0,62,69,142,5,5,8,0,0,10,0,17,198,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,2,0,2,32,0,19,226,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,29,0,19,223,0,23,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,15,189,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,3,48,0,16,238,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,4,19,192,67,82,237,0,14,216,0,22,245,0,0,0,0,0,0,0,0,0,9,15,81,83,98,249,1,5,52,0,2,25,0,18,200,0,0,0,0,0,0,0,0,0,30,38,134,109,118,217,0,0,10,0,1,20,0,18,211,0,0,0,0,0,0,0,0,0,0,0,4,15,17,32,0,0,0,0,4,63,0,23,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,47,0,21,245,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,16,196,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,13,16,55,10,31,243,0,23,253,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,6,20,186,6,20,168,0,11,126,0,21,238,0,0,0,0,0,0,0,0,0,5,6,4,120,135,255,49,53,89,0,0,0,0,10,130,0,0,0,0,0,0,0,0,0,0,0,0,24,27,63,60,66,123,0,0,0,0,2,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,118,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,15,0,11,143,0,22,245,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,16,193,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,5,80,0,23,254,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,3,15,38,255,3,23,231,0,20,231,0,20,232,0,0,0,0,0,0,0,0,0,0,9,162,36,56,248,4,18,155,0,13,162,0,21,241,0,0,0,0,0,0,0,0,8,113,123,219,62,77,226,14,16,37,0,0,0,0,12,149,0,0,0,0,0,0,0,0,0,62,70,145,80,89,177,10,12,39,0,0,0,0,9,100,0,0,0,0,0,0,0,0,0,13,13,21,40,42,68,17,18,31,0,0,0,0,11,134,0,0,0,0,0,0,0,0,0,0,0,0,9,10,15,37,39,60,0,0,22,0,20,234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,18,205,0,22,245,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,18,203,0,21,243,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,9,108,0,21,245,0,23,252,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,0,21,244,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,60,67,85,255,0,21,252,11,33,246,0,22,244,0,0,0,0,0,0,0,0,0,5,16,146,73,90,255,74,91,251,56,71,221,0,17,217,0,0,0,0,0,0,0,0,0,28,30,61,82,100,255,108,120,246,61,69,152,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,1,6,70,33,42,128,0,0,0,0,10,126,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,46,0,20,231,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,11,116,0,23,255,0,23,254,0,0,0,0,0,0,0,0,0,0,0,0,66,71,123,18,39,249,0,24,255,0,24,255,0,0,0,0,0,0,0,0,0,0,0,4,25,43,240,0,20,251,0,23,254,0,23,253,0,0,0,0,0,0,0,0,0,0,0,19,117,129,255,18,20,40,0,0,0,0,12,147,0,0,0,0,0,0,0,0,0,0,0,0,35,41,89,16,18,51,0,0,0,0,4,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,71,0,20,235,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,14,166,0,22,245,0,24,255,0,0,0,0,0,0,0,0,0,0,0,0,0,11,147,0,23,255,0,24,254,0,23,247,0,0,0,0,0,0,0,0,0,0,12,141,0,22,241,0,21,237,0,19,229,0,17,240,0,0,0,0,0,0,0,1,25,0,16,214,0,12,235,0,10,231,0,14,239,0,0,252,0,0,0,0,0,0,5,8,38,33,55,250,0,6,203,0,3,34,0,4,65,0,15,219,0,0,0,0,0,0,0,0,36,96,110,247,12,30,203,1,0,0,0,0,0,0,3,39,0,0,0,0,0,0,0,0,0,87,95,169,35,51,208,0,0,0,0,0,0,0,2,28,0,0,0,0,0,0,0,0,0,17,17,24,39,43,85,0,0,0,0,0,0,0,2,28};

that doesn't.

after a bit of searching and head scratching i found this discussion on the subject.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=80105&start=0

i was really just running this by the forum to see if it was correct or not. for my tests their defiantly seems to be a limit but i wanted a definite yes or no so as to be sure it wasn't something else. I'm not running out of sram i know that.

Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It complies fine enough, but will not up load
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you aware that carriage returns/line feeds in initializer lists have no affect?

Break that horrid statement up after every n elements, to make it easier to count them.

What does "that doesn't work" mean? The compiler doesn't like the statement? Or, the compiler doesn't mind, but the functions that access the data don't get the right data?

Is the cutoff between works/doesn't work 255 elements?
Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry, they both compile fine. but when i try to up load to the mega if i have an array above about 500 bytes the IDE locks up when it trys to up load to the mega. it does it every time and if i make the size of the array smaller it will up load. Both complie.
« Last Edit: April 23, 2012, 09:07:50 am by EVP » Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems i can get it to work with prog_uint16_t but not prog_uint8_t. prog_uchar works but  only for text
e.g

Code:
prog_uchar  rainbow_webtext [] PROGMEM = {"0,0,0,6,0,0,58,0,0,58,0,0,51,0,0,6,0,0,53,0"};

how can i use prog_uchar to store 8bit unsigned integers easily? or is their something i can do to make prog_uint8_t work.
I'm sure i'm going wrong somewhere but i cant find it.
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post a complete sketch which compiles, with setup() and loop(), trimmed down to only the smallest amount of code needed to demonstrate the problem.  It's likely something else that's happening in your sketch which is not shown here.

And btw, the linked avrfreaks thread is right, the most you can initialize in one array is 32k.
Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26293
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but when i try to up load to the mega if i have an array above about 500 bytes the IDE locks up
Depends on the data, but could this be another manifestation of the three consecutive ! "feature" of the bootloader?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: