Go Down

Topic: Why does Arduino auto-restart? (Read 33853 times) previous topic - next topic

marioquark

I'm debugging my app with several Serial.print().
I've noticed Arduino periodically restarts when running on (it seems) random points of execution...

Does it restart on errors/exceptions? Is it a correct supposition?

pluggy

No, the Arduino doesn't restart on errors. It may be a serial issue with the auto-reset, usually to do with communications software toggling the DTR liine, or it could be a power or electrical noise problem.

marioquark

thank you, but it resets in a loop at the same execution point.
other sketches are running correctly...

what could it be?

marioquark

uhm... i used the available memory function

int availableMemory()
{
  int size = 8192;
  byte *buf;
  while ((buf = (byte *) malloc(--size)) == NULL);
  free(buf);
  return size;
}

and i get 30  :P is it a RAM issue?

marioquark

i'm going crazy...
i run the availableMemory() function in an ad-hoc sketch and i get

free memory = 1785 - memory used = 6407
:-?

6407 used??? i have the ATmega328p!

AWOL


floresta

#6
Apr 18, 2010, 11:51 pm Last Edit: Apr 18, 2010, 11:53 pm by floresta Reason: 1
marioquark:

Check out this thread for some ideas:  http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262180529

Don

marioquark

#7
Apr 19, 2010, 12:18 am Last Edit: Apr 19, 2010, 12:22 am by marioquark Reason: 1
so, you think is my pc who resets arduino...
mmm could i use arduino on battery (so disconnected from USB) + manual reset, instead of cutting the hardware trace?

another question: why it doesn't happen with other sketches?

thank you for the answer!

floresta

#8
Apr 19, 2010, 02:59 am Last Edit: Apr 19, 2010, 02:59 am by floresta Reason: 1
I think it's the serial.print that you are using for debugging (mentioned in your original post) that is resetting your Arduino.  

If you disconnect your Arduino from your usb (mentioned in reply #7) you won't be able to do the debugging.

Quote

another question: why it doesn't happen with other sketches?
Do they use serial.print?

Don

marioquark

yes, the do.

ok so i could try to comment as Serial.print as possible and see what happens...

thank you.

marioquark

yes, now it works... very weird Serial.print() make this happen...
anyway thank you!  ;)

floresta

Quote
yes, now it works...
You're welcome!  Thanks for letting us know that it worked - it will help us help others in the future.

Don

joejvj

If you're arduino resets or auto-restarts all by itself, it is caused by a program crash, usually because a memory buffer or array is being written beyond the size of the array or buffer size.

floresta

#13
Apr 28, 2010, 02:38 am Last Edit: Apr 28, 2010, 02:38 am by floresta Reason: 1
JoeJ:

Quote
If you're (sic) arduino resets or auto-restarts all by itself, it is caused by a program crash, usually because a memory buffer or array is being written beyond the size of the array or buffer size.
Are you saying that Serial.print() was not the cause of his problem or are you pointing out what may be wrong within Serial.print()?

Don

Senso

Your ram stack was being overflowed, if you remove the serial.prints, all the messages that are to be printed through serial.print occupies space in ram, so if you remove then your ram as more free space.

Go Up