Issue with interrupts/millis in 0017

The following sketch should echo whatever is received on input back to output. However it does not work as is.

void setup()
{
  Serial.begin(57600); 
  //Serial.print(millis());
}

void loop()
{
  while (Serial.available())
    Serial.print(Serial.read(),BIN);
}

If I include a call to millis (remove comment in source above) however it will work. It seems to me that if there is no call to millis - any sketch using interrupts (serial input in this case) will fail.

It seems to me that the interrupt vector table gets completely screwed up when there is no call to millis().

Is this a known issue?

Hi Ben, the code works perfect on the arduino nano with millis commented out. Whatever character I send a the ascii code for the char is coming back.

Must be something different, some baudrate issue with your serial monitor or client software?

Eberhard

the code works perfec ..

Interesting - would be nice if others could try as well with version 0017 (on XP SP3).

The example I gave is constructed to highlight an issue I had with a bigger project. It's not related to serial communication specifically, but just easier to test. Also note that it doesn't require an explicit call to "millis(). If I call delay() - which in turn calls millis() it will also work.

seems to be working as expected for me also

windows XP sp3, on a "real" com port and a level converter

you might want to reload the usb/ftdi driers

I looked some more into this issue and found that it is caused by applying the following patch:

http://code.google.com/p/arduino/issues/detail?id=129

For some reason this leaves global interrupts disabled, but only when millis() is not referenced by the sketch. I tried moving interrupt enable from "init()" to "main.cxx" and the sketch then worked as expected. Such a change however would defeat the purpose of the patch.

Until the issue is understood/resolved I can only advice against applying the referenced patch.