What happens with 14400 and 28800?

I have developed a serial panel with ATMEGA328. For some reason it would work at any baud rate from 4800 to 115200 except for 14400 and 28800.

The ATMEGA328 is using the hardware UART so it's not a software library. I used the arduino duemilanove and a $5 TTL USB adapter so it is not just with the FTDI but somehow with the ATMEGA328. I wonder if anyone has seen problems with these two baud rates in their programming. Thanks.

Baud rates are only approximate and are based on the crystal frequency. It could be that the baud rate error at these two rates is too great for communications to take place.

Grumpy_Mike: Baud rates are only approximate and are based on the crystal frequency. It could be that the baud rate error at these two rates is too great for communications to take place.

Mike, I've thought about it but since baud rate as high as 115200 works just fine except for the 14400 and 2*14400 so any other possibilities? Thanks.

This line determines the serial baud rate:

baud_setting = (F_CPU / 8 / baud - 1) / 2;

I did some extensive simulations of cpu frequency being all the wa up and down to 10% off but there is no way that the 14400 and 28800 could be more than 10% off without the rest of the baud rate going more than 10% off.

Then I downloaded termite 2.6 by CompuPhase, which is a terminal. I tested out all the baud rates and my panel worked flawlessly. Then switched back to arduino IDE and tested 14400, bummer. Back to termite, yeah!

So maybe this is an IDE bug then?

liudr:

Grumpy_Mike: Baud rates are only approximate and are based on the crystal frequency. It could be that the baud rate error at these two rates is too great for communications to take place.

Mike, I've thought about it but since baud rate as high as 115200 works just fine except for the 14400 and 2*14400 so any other possibilities? Thanks.

This is not a case of faster has more error, its a case of how well the selected baud rate gets along with the crystal frequency of the UART. If your crystal is 1.845 (or something like that) then all should be good. Other speeds that are not multiples of this speed can cause errors with some baud rates but not others. There is a way to figure out exactly the percentage of error, but I forget at the moment. Google it. Your error should not exceed 3%.

I tested this program:

void setup ()
{
  Serial.begin (14400);
}

void loop ()
{
  Serial.println ("hello, world");
}

The words "hello, world" appeared in the IDE terminal monitor (this is on a Mac).

According to my logic analyzer the time between bytes was 0.6962500 mS which translates to a rate of 1436.2657. If my calculator (and my brain) is correct, this is only an error rate of under 1%.

This is on a Uno. What is your hardware setup?

The phrase you're looking for is "receiver margin".

@liudr
You can test the working range around a specific baudrate with this sketch quite easily

long ref = 115200;
long min = ref /10 * 9;     // -10%
long max = ref /10 * 11;  // +10%
long step = ref / 100;

long baudrate = min;

void setup()
{
  Serial.begin(ref);
  Serial.println("start"); 
}
void loop()
{
  if (baudrate <= max)
  {
    Serial.begin(ref);
    Serial.println();
    Serial.print(baudrate);
    Serial.print(" :  ");
    delay(100);
    Serial.begin(baudrate);
    Serial.print(baudrate);
    delay(100);
    baudrate += step;
  }
}

Thank you guys and I will do some more testing. The thing is I was able to do all baud rate fine with termite terminal program but with arduino IDE I can do every baud rate except for 14400 and 28800. That bothers me.

My hardware is duemilanove with FTDI chip and a $5 TTL USB adapter with a "SILABS CP2102" chip, neither of which has a visible external crystal.

Aha! I finally unwillingly busted out my new UNO (in an adafruit start kit I received from an arduino workshop you guys all missed:)).

The picture says 1024 words!

I am using arduino IDE 0022 on windows vista 64 home premium.

I also tested out 115200 and it worked so no need to post picture or BSO my blog monthly visit ;)

BTW, UNO has amazing upload speed. How fast is it and duemilanove?

If you do the Serial.println(“just testing”); several times in a loop does it start to work?

skyjumper: If you do the Serial.println("just testing"); several times in a loop does it start to work?

Nope. Just did 14400 28800 neither worked as I was expecting. 115200 worked as I was also expecting. I will try on a different computer but at this point I'm not going to, very soon. See my previous replies: termite terminal program works fine with all baud rates but not arduino IDE. Same program same hardware just different software end on my PC.

liudr:

skyjumper: If you do the Serial.println("just testing"); several times in a loop does it start to work?

Nope. Just did 14400 28800 neither worked as I was expecting. 115200 worked as I was also expecting. I will try on a different computer but at this point I'm not going to, very soon. See my previous replies: termite terminal program works fine with all baud rates but not arduino IDE. Same program same hardware just different software end on my PC.

Yes, the Arduino's IDE serial monitor has a few 'bugs' when it comes to baud rate selections.

Lefty

retrolefty: Yes, the Arduino's IDE serial monitor has a few 'bugs' when it comes to baud rate selections.

Lefty

Lefty, could you shed some light on this issue? Thanks.

Honestly I've never even tried to test all baud rate in the past on any of my arduino and variants, under the assumption that if it works at 115200, it should at all lower rates.

I've got an official 2009 with a 168, using 0021, on a Windows 7 machine.

void setup()
{
 Serial.begin (28800); 
}

void loop ()
{
  Serial.println ("The quick brown fox");
  delay (1000);  
}

Works perfectly at 14400 or 28800.

AWOL: I've got an official 2009 with a 168, using 0021, on a Windows 7 machine.

void setup()
{
 Serial.begin (28800); 
}

void loop () {   Serial.println ("The quick brown fox");   delay (1000);  }




Works perfectly at 14400 or 28800.

I'll definitely try other computers then. I used serial monitor on arduino ide 0018 at 28800 it fails again. Switch back to termite, works no problem. :(

The only place where the data is in serial form is from the ATmega chip to the USB / Serial bridge chip. There is no serial communications taking place between the board and the computer nor inside the computer or in the serial monitor.

So any error must involve that link between the two chips, OR the way the host program on the PC communicates the baud rate request to the USB drivers.

liudr: I used the arduino duemilanove and a $5 TTL USB adapter so it is not just with the FTDI but somehow with the ATMEGA328.

...

liudr: The thing is I was able to do all baud rate fine with termite terminal program but with arduino IDE I can do every baud rate except for 14400 and 28800. That bothers me.

I'm confused now. Your original post said you had a problem with the Atmega328, so I tested that with mine and found no problem. Now you say it works fine with terminal programs, but not the IDE.

So really, your problem is with the IDE and not the Atmega?

Lefty, could you shed some light on this issue? Thanks.

Honestly I've never even tried to test all baud rate in the past on any of my arduino and variants, under the assumption that if it works at 115200, it should at all lower rates.

It's been some time and many IDE versions ago, so I can't recall the details, but I'm sure I was seeing baudrate garble problems with just the IDE's serial monitor on some baudrates when I ran some simple tests. May or may not still be the case but seeing your test results reminded me of those past things I saw.

Anyway just ran tests at all Arduino IDE serial monitor baudrate options offered (why is there no 600 baud option?), and all speeds ran fine, except for 300 baud which garbles. I seem to recall that is because of some baudrate divider option (doublespeed?) bit is set up in the AVR by either the bootloader or the serial library.

Anyway this latest test was performed on a Seeeduino FTDI equiped mega board, IDE 22, Windows XP pro SP3.

Lefty