Macintosh: Serial Port Configurations for Nonstandard Baud Rates


Inside Macintosh, Volume II (pages 250-251) tells how to configure for
eleven baud rates: 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600,
19200, and 57600.

Here's how to configure for other values.

For example, to obtain 38,400 baud rate on your serial port, the correct
value to pass to SerReset is "1" for the baud rate constant.

Note that you can specify a given baud rate by making the serial driver
control call with a control (csCode) of 13. The driver will return the
closest baud rate that the serial driver will generate. This is documented
in Inside Macintosh, Vol. II-254.

Some trivia:

The formula for figuring out the SerConfig baud rate constants is:

114709
Baud Rate Constant = ----------- - 2.0
Baud Rate

For example, the baud rate constant for 9600 baud is:

114709
Baud Rate Constant = ----------- - 2.0 = 11.949 - 2.0 = 9.949 = 10
9600

The 114709 figure comes from the SCC clock (3.670702 MHz) which comes from
the system clock (15.6672 MHz), but doesn't divide down evenly because of
the timing PALs (in fact 3.670702 = 15667200 /4 * 15/16, where the 15/16 is
due to PAL timing). For the MacXL (Lisa), use 115200 instead of 114709.

Similarly, you can do a reverse calculation and find the baud rate, given
a constant. Reversing the formula, you get:

114709
Baud Rate = --------------------------
Baud Rate Constant + 2.0

So, using the constant 10 (for 9600 baud), the formula gives

114709
Baud Rate = -------------------------- = 9559.083
10 + 2.0

This isn't exactly 9600 baud. In fact the error percentage is:

9559.083
1.0 - -------------- = 1.0 - 0.996 = 0.426%
9600

If you try this with 38400, you get:

114709
Baud Rate Constant = --------- - 2.0 = 2.987 - 2.0 = 0.987 = 1,
38400

a baud rate of:

114709
Baud Rate = -------------------------- = 38236.333,
Baud Rate Constant + 2.0

and an error percentage of:

38236.333
1.0 - -------------- = 1.0 - 0.996 = 0.426%
38400



Published Date: Feb 18, 2012