Serial.print cause Uno to lockup if USB not connected?

Hello All!

I was having a freezing issue with my Uno. About 24-30 hours after the program started to run the arduino would suddenly lock and I think I found the problem but I want to see if the solution I found is reasonable.

I had a couple lines using the Serial.println command that I neglected to remove, but there was nothing plugged into the USB port. I found on the web someone saying they thought that in this case the data is buffered waiting for the ability to transmit. If the buffer fills the Uno locks up.

This explanation would meet the symptoms exactly, but the person that said that wasn't sure,.. and it was an article written on V 1.0 of the software not the current version. SO I was wondering,.. is this possibly the cause of my problem?

I have pulled the extra lines, and the Arduino is plugging along now but it will be a week before I'm totally sure it worked.

Thank you!
Whiskey

You probably are using too much RAM. Removing the print lines might solve the problem by saving some RAM, but printing without the USB should not cause that. The UNO just throws those bytes away. Besides the serial transmit buffer is only 64 bytes. Did it take you a month to print that much?

Are you using Strings? your memory might be getting fragmented.

If the Serial data really was buffering waiting to be printed out, it would make sense that the Uno would freeze. It basically runs out of memory. The only thing (I think) you can do is wait and see if it freezes again.

Best of luck!
-Austin

KeithRB:
You probably are using too much RAM. Removing the print lines might solve the problem by saving some RAM, but printing without the USB should not cause that. The UNO just throws those bytes away. Besides the serial transmit buffer is only 64 bytes. Did it take you a month to print that much?

Are you using Strings? your memory might be getting fragmented.

It is allot of code, 24 pages if printed in Word, but when I compile I am told that Global variables use only 38% of the memory, and the sketch uses only 46% of program space.

It takes 24-30 hours to lock,.. I am not using strings that I am aware of.

Thank you for your help!
Whiskey

There are various things that could cause your UNO to appear to lock up, so I suggest you post your code (or attach it, if it is too big to post inline) so that people can tell you whether you're doing anything dangerous. Straight forward serial port output won't lock the UNO up - it makes no difference to the UNO whether anything is connected to the serial port, it will just keep pushing bits out regardless.

austinkregel:
If the Serial data really was buffering waiting to be printed out, it would make sense that the Uno would freeze.

Yes but it does not.

It can only back up in the buffer if it uses handshaking to hold the sending until something is ready to recieve it. This does not happen. Also the code for the buffer in the arduino does not look to see if it is full.

PeterH:
There are various things that could cause your UNO to appear to lock up, so I suggest you post your code (or attach it, if it is too big to post inline) so that people can tell you whether you're doing anything dangerous. Straight forward serial port output won't lock the UNO up - it makes no difference to the UNO whether anything is connected to the serial port, it will just keep pushing bits out regardless.

Okay,.. I'd love for someone to look this over. I'm not sure how understandable it will be though.

Nevermind,.. It goes way over the max of 9500 charictors. :frowning:

I know how to attach a picture, but how do I attach code?

In the edit window, click on Additional Options and then click the browse button to select your sketch file(s).

It's funny, I understand that it shouldn't but after removing the serial.println commands from the code the Arduino has stopped locking up.

Maybe some static glitch or something with the cable that is always plugged into the USB port?

Thank you!
Whiskey