Go Down

Topic: Program execution resets with no serial connection (Read 676 times) previous topic - next topic

asinc

Feb 20, 2013, 02:45 pm Last Edit: Feb 20, 2013, 03:02 pm by asinc Reason: 1
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?

JimboZA

Presumably you have the Arduino connected to another power source?
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

HazardsMind

My GitHub:
https://github.com/AndrewMascolo?tab=repositories

asinc


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.

HazardsMind


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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

holmes4

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

asinc



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

retrolefty


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

holmes4

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: [Select]
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

retrolefty


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: [Select]
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


HazardsMind

I believe its a 10k resistor from reset to ground

Reset => 10K => GND

I think, but maybe Lefty knows for sure.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up