Go Down

Topic: array-BUG (Read 1 time) previous topic - next topic

Joegi

Aug 15, 2013, 06:16 pm Last Edit: Aug 15, 2013, 06:19 pm by Joegi Reason: 1
...the following code crashes the Atmega and leads to strange behaviour of it!
ONLY RUN IT WITH NOTHING CONNECTED TO THE ARDUINO!
Code: [Select]
byte a[6000] = {1};
void setup()
{
 pinMode(13, OUTPUT);
}
void loop()
{
 a[5] = 10;
 digitalWrite(13, HIGH);
 delay(1000);
 digitalWrite(13, LOW);
 delay(1000);
}


The reason is the length of the array. If you shorten it, everything works fine!
I only tested the code on two UNOs!

Joegi

#1
Aug 15, 2013, 06:28 pm Last Edit: Aug 15, 2013, 06:30 pm by Joegi Reason: 1
...oh stupid me, I forgot that the Atmega 328P only has two kbytes of static RAM, but the program shouldn't upload!

ajk_

Well, other than the fact that the ancient G++ version has issues with initialized arrays to begin with... I've run into this bug myself, and I'm forced to init global arrays manually every time because of old tools and work around all sorts of other odd bugs.

See link here http://forum.arduino.cc/index.php?topic=184131.0 and get on to git-hub, and complain with a bug report about outdated tools.

Coding Badly

Well, other than the fact that the ancient G++ version has issues with initialized arrays to begin with...


Please post a complete sketch that illustrates the problem.

ajk_

Not a complete sketch, and not G++, but GCC (which iirc uses GCC anyway)
http://forum.arduino.cc/index.php?topic=184131.msg1372344#msg1372344
;-)

Go Up