[comp.os.msdos.programmer] Setting BAUD rate with MODE command

randys@cpqhou.uucp (Randy Spurlock) (01/09/91)

in article <1991Jan9.003303.18953@thyme.jpl.nasa.gov>, kaleb@thyme.jpl.nasa.gov (Kaleb Keithley) says:
> 
>>
>> ***** Real message deleted *****
>>
> 
> If you RTFM, the one you got when you bought DOS.... you did buy it didn't
> you?  You will see that 19200 is indeed invalid.
> 
> That's because if you look at how mode is implemented, i.e. braindead....
> oops, I mean with a BIOS function call, and how the BIOS is implemented, 
> packing all the parameters into a register, such that the value derived 
> for 19200 is larger than will fit into the bits allocated for the baud, 
> you will see that 19200 is indeed an invalid baud rate.
> 
> Now, since you're looking at the BIOS listings to see this, you can 
> plagarize your own version of mode that doesn't try and pack baud, parity, 
> and stop bits into one sixteen bit register, and therefore skirt the bogus
> baud rate warning.
> 
> Have fun.
> -- 
> Kaleb Keithley                      Jet Propulsion Labs
> kaleb@thyme.jpl.nasa.gov
> 
> Offensive quote coming soon to a .signature file near you.

I hate to be picky, but since I developed the mode command for MS-DOS 3.0
and programmed BIOS ROM's, I have to take offense! If you would read the
data sheet for the Intel 8250, the original asynch. chip used in PC's, you
would have seen that the data sheet said the baud rate generator was only
good up to 9600 baud, even though you could program it up to 115.2 Kbaud,
and my experience is that 19.2 Kbaud works on every machine I have tried.
But to be fair to us "brain-dead" BIOS coders we simply followed the data
sheet recommendations and only supported up to 9600 baud :)!


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
          - Randy Spurlock -	      |      Compaq Computer Corporation    
---------------------------------------------------------------------------
These opinions are mine...all mine... | He fired his hyper-jets and...  
just ask anyone who's heard them!     | blasted into the 5th dimension!
--------------------------------------| 
UUCP: ...!uunet!cpqhou!randys         |                     Space Man Spiff
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 

miller@b-mrda.ca.boeing.com (Mark Miller) (01/10/91)

I think you'll have to do it yourself in your application. For a good 
discussion of the topic of serial comm, see the MS-DOS Encyclopedia or
Ray Duncan's Advanced MS-DOS. I believe Peter Norton's "Programming the
IBM PC & PS/2" also touches on the topic.

Hope this helps.
------------------------------------------------------------------------------
Mark R. Miller                     | 
Boeing Commercial Airplane Company | 
Seattle, WA                        | 
Internet: miller@b-mrda.boeing.com | 
Voicenet: (206) 237-0960           |  
------------------------------------------------------------------------------
Opinions expressed here do not necessarily reflect those of my employer.
------------------------------------------------------------------------------

kaleb@thyme.jpl.nasa.gov (Kaleb Keithley) (01/10/91)

In article <1991Jan09.150149.15065@cpqhou.uucp> randys@cpqhou.uucp (Randy Spurlock) writes:
>
>I hate to be picky, but since I developed the mode command for MS-DOS 3.0
>and programmed BIOS ROM's, I have to take offense! If you would read the
>data sheet for the Intel 8250, the original asynch. chip used in PC's, you
>would have seen that the data sheet said the baud rate generator was only
>good up to 9600 baud, even though you could program it up to 115.2 Kbaud,
>and my experience is that 19.2 Kbaud works on every machine I have tried.
>But to be fair to us "brain-dead" BIOS coders we simply followed the data
>sheet recommendations and only supported up to 9600 baud :)!
>

Asbestos suits on folks...  I smell a flame fest.

Lighten up!  I never said the people who implemented were brain-dead; maybe 
you were looking for something that wasn't there?  Just for the record, I 
did read the Intel data sheet (over five years ago), in fact that's how I 
figured out that I could make the 8250 work at 19200...  (It certainly
wasn't because of anything in the IBM PC BIOS listings.) 

It is my opinion though, that cramming every parameter into a single
register was a tad short-sighted.  Jeez, you left at least two registers 
unused.  Might it not have made more sense to use BX for the baud and CX 
or DX for the stop bits and parity bits....  Also, when you look at the
code in MODE, to pack the data into one register, and the code in the BIOS
to unpack the register...  (And people wonder why companies like Lotus
circumvent DOS and BIOS to squeeze every last little bit of performance
out of their product.)  Then, when technology advanced a little bit 
(God forbid technology should advance) then you wouldn't be hamstrung 
trying to be backwards compatible?  Isn't hind-sight wonderful?

-- 
Kaleb Keithley                      Jet Propulsion Labs
kaleb@thyme.jpl.nasa.gov

Offensive quote coming soon to a .signature file near you.

valley@uchicago (Doug Dougherty) (01/10/91)

randys@cpqhou.uucp (Randy Spurlock) writes:

>I hate to be picky, but since I developed the mode command for MS-DOS 3.0
>and programmed BIOS ROM's, I have to take offense! If you would read the
>data sheet for the Intel 8250, the original asynch. chip used in PC's, you
>would have seen that the data sheet said the baud rate generator was only
>good up to 9600 baud, even though you could program it up to 115.2 Kbaud,

I think the point is not to start a flame war but that it would be nice
if there someone would post a simple (obviously, non-INT 14) way of
setting the higher baud rates.  I'd sure appreciate it, that's for sure.

w8sdz@vela.acs.oakland.edu (Keith Petersen) (01/10/91)

ted@helios.ucsc.edu (Ted Cantrall) writes:
>We've been trying to set the baud rate of COM1 to 19,200. Every other rate
>is accepted but that one. We've used every permutation of 1-9-2-0-0.
>The DOS is 3.30 on an AT clone with AMI BIOS and 4DOS installed.
>The error message is "invalid baud rate".

This program, available via anonymous FTP from WSMR-SIMTEL20.ARMY.MIL
[26.2.0.74], will do what you want.

Directory PD1:<MSDOS.SYSUTL>
 Filename   Type Length   Date    Description
==============================================
TOADMOD1.ARC  B    4949  890427  Set COM 1-4 to 19200/38400/57600/115200 bps

It's also available from Detroit Download Central.

Keith
--
Keith Petersen
Co-SysOp, Detroit Download Central 313-885-3956 (212/V22bis/HST/V32/V42bis)
Internet: w8sdz@vela.acs.oakland.edu,  w8sdz@eddie.mit.edu,  w8sdz@brl.mil
Uucp: uunet!umich!vela!w8sdz                         BITNET: w8sdz@OAKLAND

yawei@bronze.ucs.indiana.edu (mr. yawei) (01/11/91)

Setting the baudrate divisor in UART to 6 would give you a 19200 baud
rate. (Doubles the divisor halves the baudrate, etc.)  The baud rate
divisor is a 16bit register, with high byte at port 3F9h(Com1:) and 
low byte at 3F8h. Bit 7 of line control register must be on when 
accessing the baudrate divisor.

To set Com1: to 19200b, 8data bits, 1 stop bits, no parity, do:

  Send 80h to 3FBh         ;line control register
  Send 00h to 3F9h         ;high byte
  Send 06h to 3F8h         ;low byte
  Send 03h to 3FBh         ;8 data bits, etc.

The base address (3F8h) of com1 can be found at 0040:0000, and com2
at 0040:0002. It is a better idea to get it from here than just assume
it to be 3F8h etc, as it allows softwares that swap com ports to work.

Ya-Gui Wei
a.k.a. yawei