5

I am trying, unsuccessfully to communicate, using my Arduino Nano, with a custom device at a baud rate of 800 kbit/s.

The Arduino code look like this:

void setup() {
  // Put your setup code here, to run once:
  Serial.begin(800000);
}

void loop() {
  // Put your main code here, to run repeatedly:
  delay(5000);
  Serial.println(0x2be1);
}

When I am trying to debug it with PuTTY the result is:

PuTTY output @ 800 kb/s

And when I change the baud rate to 400 kbit/s the result is (as it should be):

PuTTY output @ 400 kb/s

Any idea?

14

The Arduino Nano cannot do 800 kb/s. As you can see in the source code, the bit duration is rounded to the nearest multiple of 8 CPU cycles. In your case, it is rounded to 3 × 8 CPU cycles, which yields a baud rate of 666.666 kb/s. That is 16% too slow, an error too large for any communication to be possible.

At 400 kb/s there is no rounding error, so everything works fine.

Edit: Note that if you build your own barebones Arduino, then either a 12.8 MHz or a 19.2 MHz crystal should allow you to get that exact baud rate. But then millis(), delay() and co. would all be off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.