Serial_set_baud_rate(9600); for 20 mhz and 16 mhz clocks

I have a baby-O running simple firmware that works fine. I’m now transferring the code to an …Uno.
The problem that I have is with the “serial_set_baud_rate(9600);”. The baby-O is running at 20 Mhz and the …Uno is running at 16 Mhz. What do I have to do to make the “serial_set_baud_rate(9600);” work correctly with the …Uno?. Of course both controllers are using the 328p.

I’m NOT using an IDE, just using make in the baby-O directories. I use avr-dude to program both boards. Port the code to the IDE?

Thanks all for your help.


In your code, you can change 9600 to 12000.

- Amanda

Thank you Amanda for your quick reply.

I already tried your suggestion, trying to debug the problem. Of course your suggestion doesn’t work. Since my baby-O is running at 20 mhz and the Uno that I’m using runs at 16 Mhz. I’m trying to use the code that runs on the baby-O on the Uno. Different clocks prevent from setting the correct baud rate. I’m NOT trying to connect the baby-O and Uno to talk to each other. I’m using a bluetooth HC-05 module to talk to my host.

But yesterday I found a post on the forum, that did the trick! Tried it and it worked. Looks like the post on the forum was posted in 2008. But it appeared as a new topic. Here’s the link to the post on your forum: I/O question in programming

Since this suggestion worked, I CAN now communicate with the Uno at 9600 baud.

Thank you again for your prompt reply. I wish to send an addendum to my original post, as a solution, but don’t know how.



I/O question in programming

Adam, Just noticed that one of the PC pins/IR does respond at the LV-168. While connected three stay at Nesw no…

](I/O question in programming)

Changing the argument of serial_set_baud_rate from 9600 to 12000 should have increased the AVR’s baud rate by a factor of 1.25, canceling out the slowdown caused by moving your code from a 20 MHz processor to a 16 MHz processor. I am not sure why it did not work for you, but I am glad you found a solution.

You can click on the pencil icon (second) to the left of the “Reply” button in the bottom-right corner of the post you want to edit.

- Amanda

Thanks again for you quick reply.

I will try again the 1200 baud rate setting, and will let you know if it worked.



You probably made a typo, but just in case, the value should be 12000 (12,000), not 1200 (1,200).

- Amanda

I thought that it was your typo and you meant, 1200 baud.

But did try the 12000, as you suggested and it worked! !

I did come up with the 1.25 ratio, and didn’t accept the 12000, it didn’t seem right.

I didn’t know that the serial_set_baud_rate() function would allow something other than the set of standard baud rates.Thank you very much for your help. Your suggestion keeps my firmware simple, as intended.

Thanks again