Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Error in Software Serial Documentation - halfBitDelay should be placed before if (low) check

Open iUnknwn opened this issue 13 years ago • 1 comments

In the software serial documentation of the SWread function, the description says it ways for a low, then waits half a bit before re-checking to ensure that the low was not line noise.

However, the code performs the delay after the for loop already starts:

 while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);

Shouldn't this be something like this instead:

 while (true)
{
  while (digitalRead(rx));
  //wait for start bit
  delayMicroseconds(halfBit9600Delay);
  //if still low, break loop and proceed.
  if (digitalRead(rx) == LOW) { break; }
}

iUnknwn avatar Mar 12 '13 18:03 iUnknwn

@szim90 What page of the documentation do you see this?

shfitz avatar Nov 04 '13 07:11 shfitz