Pages: [1]   Go Down
Author Topic: Program execution resets with no serial connection  (Read 546 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: February 20, 2013, 09:02:13 am by asinc » Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3863
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Presumably you have the Arduino connected to another power source?
Logged

The Elders of the Internet know who I am.....

Queens, New York
Offline Offline
Faraday Member
**
Karma: 86
Posts: 3466
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some code would be nice.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes an external supply is connected.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Queens, New York
Offline Offline
Faraday Member
**
Karma: 86
Posts: 3466
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2211
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2211
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
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

Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 86
Posts: 3466
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe its a 10k resistor from reset to ground

Reset => 10K => GND

I think, but maybe Lefty knows for sure.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: [1]   Go Up
Jump to: