Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Baud rate calculations
From: Björn Stenberg (bjorn_at_haxx.se)
Date: 2001-12-09


I need a second pair of eyes here. Maybe I haven't slept enough this
weekend... :-)

I'm looking at the setup code for serial port 1. It sets SMR1 to 0 which means
"asynch mode, bits 8N1, no clock divisor (n)". Then it sets BRR1 to 255. BRR1
is the baud rate register.

The BRR setting is calculated as follows (p359):
  Asynchronous mode
    N = [f/(64 * 2^(2n-1) * B)] * 10^6 - 1

 B: Bit rate (bits/s)
 N: BRR setting for baud rate generator (0 <= N <= 255)
 f: f frequency (MHz)
 n: Baud rate generator clock source (n = 0, 1, 2, 3)

So what bit rate do we have? Breaking out B from the above should be:

 B = [f / N / (64 * 2^(2n-1)] * 10^6 - 1

N=255, n=0, f=12 gives me:

 12/255/(64*(2^-1))*10^6-1 = 1469.588 bps

1470 bps? Please someone doublecheck my math.

/Björn



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa