'=========================================================================== ' Subject: COM ROUTINES Date: 11-09-95 (02:12) ' Author: Chad Beck Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: MODEM.ABC '=========================================================================== ' > I am STILL in need of a routine to initialize com ports 1 through 4 ' > at speeds up to hopefully 115,200bps... My routines have stopped ' > working. I do NOT need any routines for writing/reading port data, ' > all I need is something to set the bps rate, and maybe the parity, ' > data bits, and stop bits as well. Doesn't anyone have source that ' > meets these requirements? ' Alright, alright. You've suffered long enough. To set the BPS 'rate, first you need to calculate the Baud Rate Divisor, then set bit 7 'of the Line Control Register on, then write the Baud Rate Divisor, the 'set bit 7 of the Line Control Register back off. This is untested: BRD = 1843200 \ (16 * BitRate) 'calculate Baud Rate Divisor Byte = INP(ComAddress + 3) OR 128 'set bit 7 of LCR high OUT ComAddress + 3, Byte OUT ComAddress + 1, BRD \ 256 'MSB of BRD OUT ComAddress, BRD AND 255 'LSB of BRD Byte = INP(ComAddress + 3) AND 127 'set bit 7 of LCR low OUT ComAddress + 3, Byte ---***--- The Parity, Data & Stop bits are easier: OUT ComAddress + 3, Byte The bit values of Byte are as follows (I'll spare the high ASCII): ------------------------------------------------------------------------ | Bit # Meaning Setting | |----------------------------------------------------------------------| | 0-1 Character length | | 5 bits 00 | | 6 bits 01 | | 7 bits 10 | | 8 bits 11 | | 2 Stop bits | | 1 bit 0 | | 1.5 bits 1 (5-bit characters) | | 2 bits 1 (6, 7 & 8-bit characters) | | 3-5 Parity | | Ignore 000 | | Odd 100 | | Even 110 | | Mark 101 | | Space 111 | | 6 Break condition | | Disabled 0 | | Enabled 1 | | 7 Port toggle | | Normal 0 (use THR/RDR & IER registers) | | Alternate 1 (use BRDL & BRDH registers) | | | ------------------------------------------------------------------------ So, for instance, 8 data bits, 1 stop bit and no parity is 00000011 binary (3) while 7 data bits, 1 stop bit and even parity is 00011010 binary (26). Make sense? Let's hope so.