Pages: [1]   Go Down
Author Topic: arduino reset when instantiating an object  (Read 564 times)
0 Members and 1 Guest are viewing this topic.
Stockholm
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm experiencing an strange reset problem.

It seems that arduino resets when I do
Code:
 struct zigbee a;
  XBee xbee(a);

The XBee class and the struct zigbee forms part of an XBee library I'm developing.

The XBee class has a bunch of functions but I'm not calling any of those functions(I commented out all calls to xbee.xxxx() in the sketch).

The strange thing is that this reset doesn't seem to be related with any code running on XBee constructor neither, because I commented out all statements inside the constructor and the reset keeps ocurring. The reset always comes when instantiating the object. The funny part is that if I remove/change the a string literal from "12345678" to "1234567" on the XBee class then it doesn't reset anymore. But that code that I'm changing it's never executed!!. I never call that code

So I'm wondering if it could be a linking error or something like that.

My real question is how to I debug such an error? Do I need to buy an JTAG debugger, (AVR Dragon?) or is there any way to spot the problem usign avr-objdump?

What could I do to find out what's happening?

Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like typical out of RAM behavior.

-j

Logged

Stockholm
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm pretty new at this so it didn't occur to me that arduino has a pretty limited amount of RAM. It seems that this could be the cause indeed. I'm using a lot of Serial.print("debug statements") and as I read on http://itp.nyu.edu/~gpv206/2008/04/making_the_most_of_arduino_mem.html this literals take ram space as well.

Thank you very much, from now on I will keep an eye on the RAM usage.
Logged

London
Offline Offline
Faraday Member
**
Karma: 10
Posts: 6248
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can put the string constants in program memory (flash). This page has some examples: http://www.arduino.cc/en/Reference/PROGMEM
Logged

Pages: [1]   Go Up
Jump to: