Program execution resets with no serial connection

I have a project where the arduino will collect data while not connected to the PC. Once connected to the PC it sends info out the serial port. It seems that if I don't have the usb connected to the PC that the program will not run. If I leave the pc connected then all functions fine. What am I missing?

Presumably you have the Arduino connected to another power source?

Some code would be nice.

Yes an external supply is connected.

Actually I just confirmed that the program does continue to run. The problem appears to be that once the USB is plugged into the PC, that the arduino reboots and starts execution again.

asinc:
Actually I just confirmed that the program does continue to run. The problem appears to be that once the USB is plugged into the PC, that the arduino reboots and starts execution again.

Yes, that is what it supposed to do, unless you disable the reset feature.

Two things,

  1. when you open the serial monitor it will reset the Arduino.

  2. As I understand it serial will hang when its buffer is full.

Mark

Written as you where posting

HazardsMind:
Yes, that is what it supposed to do, unless you disable the reset feature.

and how do I do that?

So many quick responses! Thanks

holmes4:
Two things,

  1. when you open the serial monitor it will reset the Arduino.
    Yes, Irregardless if your using serial statements in your sketch or not.

  2. As I understand it serial will hang when its buffer is full.

No, the serial buffers, if overfilled, will just wrap around thus loosing characters but it will still continue to receive and send characters.
Lefty

Mark

Written as you where posting

No, the serial buffers, if overfilled, will just wrap around thus loosing characters but it will still continue to receive and send characters.
Lefty

Not according to the hardwareSerial code

size_t HardwareSerial::write(uint8_t c)
{
  int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
	
  // If the output buffer is full, there's nothing for it other than to 
  // wait for the interrupt handler to empty it a bit
  // ???: return 0 here instead?
  while (i == _tx_buffer->tail)
    ;
	
  _tx_buffer->buffer[_tx_buffer->head] = c;
  _tx_buffer->head = i;
	
  sbi(*_ucsrb, _udrie);
  // clear the TXC bit -- "can be cleared by writing a one to its bit location"
  transmitting = true;
  sbi(*_ucsra, TXC0);
  
  return 1;
}

Mark

holmes4:

No, the serial buffers, if overfilled, will just wrap around thus loosing characters but it will still continue to receive and send characters.
Lefty

Not according to the hardwareSerial code

size_t HardwareSerial::write(uint8_t c)

{
 int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;

// If the output buffer is full, there's nothing for it other than to
 // wait for the interrupt handler to empty it a bit
 // ???: return 0 here instead?
 while (i == _tx_buffer->tail)
   ;

_tx_buffer->buffer[_tx_buffer->head] = c;
 _tx_buffer->head = i;

sbi(_ucsrb, _udrie);
 // clear the TXC bit -- "can be cleared by writing a one to its bit location"
 transmitting = true;
 sbi(
_ucsra, TXC0);
 
 return 1;
}




Mark

I was speaking in reference to the receive buffers which the user has no control over if they continue to receive characters from an external source but are not read out of the 'growing' buffer by the sketch in due time.

The transmit buffer, if filled, just becomes a 'blocking' command and will empty the buffer in due time based on the baud rate being used, so nothing is lost on the transmit side, it just 'stalls' your sketch until it's not full.

Lefty

I believe its a 10k resistor from reset to ground

Reset => 10K => GND

I think, but maybe Lefty knows for sure.