Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: array-BUG  (Read 969 times)
0 Members and 1 Guest are viewing this topic.
cologne, germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 74
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...the following code crashes the Atmega and leads to strange behaviour of it!
ONLY RUN IT WITH NOTHING CONNECTED TO THE ARDUINO!
Code:
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!
« Last Edit: August 15, 2013, 11:19:59 am by Joegi » Logged

cologne, germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 74
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...oh stupid me, I forgot that the Atmega 328P only has two kbytes of static RAM, but the program shouldn't upload!
« Last Edit: August 15, 2013, 11:30:19 am by Joegi » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 216
Posts: 13140
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: