Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!caip!sri-spam!mordor!jdb From: jdb@mordor.ARPA (John Bruner) Newsgroups: net.micro.mac Subject: Re: Mac serial port Message-ID: <13599@mordor.ARPA> Date: Tue, 29-Jul-86 12:30:48 EDT Article-I.D.: mordor.13599 Posted: Tue Jul 29 12:30:48 1986 Date-Received: Wed, 30-Jul-86 00:34:45 EDT References: <154@gt-eedsp.UUCP> Reply-To: jdb@mordor.UUCP (John Bruner) Distribution: na Organization: S-1 Project, LLNL Lines: 63 Keywords: MAC serial, port >I am looking for info on how to initialize the serial port on the Macintosh >for baud rates below 110 baud. Help! According to *Inside Macintosh*, the baud rate is established by performing a SerReset on the driver. The low 10 bits of the parameter specify the baud rate (the 6 bits control character size, parity, and stop bits). This 10-bit number is a timing constant. Although Apple provides the values for the standard baud rates from 300 to 57600, they don't indicate how these values are computed. (Aside: This was a really poor design decision. Not only is the programmer interface horrible, but these magic numbers are tied to the serial chip and clock rate used in the Macintosh. If Apple ever wants to use different hardware then we'll all lose (again). They should have used, say, 5 bits to encode all possible baud rates and used a table lookup in the serial driver to determine the correct time constant.) I don't have a copy of the data sheet for the Zilog 8530, but it appears that the baud rate constants obey the formula (2 * 57600) - 600 time_constant = round ( ----------------- ) - 2 baud_rate According to this, the time constant for 110 baud should be 1040. Since the field in the SerReset() argument is only 10 bits wide, the maximum time constant that can be specified is 1023. The discrepancy is 17/1040 or 1.6% Multiplying by 11 (start bit, 8 data bits, 2 stop bits), this means that the Macintosh will differ from true 110 at the end of the last stop bit by 0.18 bits. (BTW, 134.5 baud is possible, if anyone wants that. :-) I hacked up a copy of my UW program to allow it to run at the lowest possible baud rate. From my understanding of the way that UARTs work, I expected it to be able to receive OK at 110 (since they try to sample near the middle of the signal bits, allowing for some slop). As I expected, I was able to talk to the VAX here. (Life at 110 baud is really depressing.) I don't know whether or not the Mac can communicate with the standard 110 baud device, the model 33 Teletype (assuming that the current-loop vs. EIA issues are dealt with). I do not know what sort of tolerance the [AK]SR-33 has to timing errors. (I fear that it won't be very tolerant, since it is mechanical and it "knows" that its line frequency is exactly 60Hz.) A secondary effect of the Mac running slightly fast is that there will effectively be 1.8 stop bits instead of 2. I assume that the Mac uses the Z8530 in divide-by-16 mode. If so, it may be possible to reduce the baud rate by a factor of 4 by putting the chip in divide-by-64 mode. However, you'll have to write to the device register directly, and I can't speculate about how that will work if the serial driver is also periodically writing the register. I suppose you could use external clocking to achieve a lower baud rate. -- John Bruner (S-1 Project, Lawrence Livermore National Laboratory) MILNET: jdb@mordor [jdb@s1-c.ARPA] (415) 422-0758 UUCP: ...!ucbvax!decwrl!mordor!jdb ...!seismo!mordor!jdb