owen@gt-eedsp.UUCP (Owen Adair) (07/28/86)
[line eater line eater] I am looking for info on how to initialize the serial port on the Macintosh for baud rates below 110 baud. Help! Any language including basic (snicker snicker).... -- Owen Adair, Digital Signal Processing Lab, Ga. Institute of Technology uucp ... !{akgua,allegra,hplabs,ihnp4,seismo,ulysses}!gatech!gt-eedsp!owen Disclaimer: My employer is not responsible for, nor does it care, what I say here or anywhere else.
jdb@mordor.ARPA (John Bruner) (07/29/86)
>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
bart@reed.UUCP (07/29/86)
In article <154@gt-eedsp.UUCP> owen@gt-eedsp.UUCP (Owen Adair) writes: > I am looking for info on how to initialize the serial port on the Macintosh > for baud rates below 110 baud. Help! { take a baud rate (e.g. 50, 19200), and return the clock time constant } { analogous to the defined IM constants (e.g. baud19200). This returns } { the same values as IM over the the set of IM defined constants. This } { information is based on Zilog's Z8530 manual and the Hardware chapter } { of IM. Note that the value for 56Kbaud is minimal, and that too low } { a baud rate will return a value too large for the 16 bit counter in } { the SCC. } function baudclock( baud : longint ) : integer; const clockfreq = 3.672E6; { basic baud clock frequency in Hz } clockdiv = 16; { the SCC has been told to divide by this } begin baudclock := round( clockfreq / ( 2 * clockdiv * baud ) ) - 2 ); end; Bart Massey UUCP: ..tektronix!reed!bart
bart@reed.UUCP (07/29/86)
In article <154@gt-eedsp.UUCP> owen@gt-eedsp.UUCP (Owen Adair) writes: > I am looking for info on how to initialize the serial port on the Macintosh > for baud rates below 110 baud. Help! { take a baud rate (e.g. 50, 19200), and return the clock time constant } { analogous to the defined IM constants (e.g. baud19200). This returns } { the same values as IM over the the set of IM defined constants. This } { information is based on Zilog's Z8530 manual and the Hardware chapter } { of IM. Note that the value for 56Kbaud is minimal, and that too low } { a baud rate will return a value too large for the 16 bit counter in } { the SCC. } function baudclock( baud : longint ) : integer; const clockfreq = 3.672E6; { basic baud clock frequency in Hz } clockdiv = 16; { the SCC has been told to divide by this } begin baudclock := round( ( clockfreq / ( 2 * clockdiv * baud ) ) - 2 ); end; Bart Massey UUCP: ..tektronix!reed!bart