Serial Port Address; Baud Rate Selection - Brainboxes RS422 Manual

Hide thumbs Also See for RS422:
Table of Contents

Advertisement

AT & OPTO DUAL RS422/485
The following steps will be explained:-
i)
Setting the baud rate.
ii)
Setting data word length, parity and stop bits.
iii)
Setting output lines RTS and DTR.
iv)
Reading the state of input lines CTS, DSR and DCD.
v)
Detecting incoming data, RXD.
vi) Sending outgoing data, TXD.

Serial Port Address.

The address of the serial port is used to access the chip it is
placed in the variable S.

Baud Rate Selection.

Baud rate selection is made by writing an 16 bit value, as
two 8 bit bytes to the Divisor Latch Registers.
To set the baud rate the correct divisor, RATE, for the chip must
be determined. See line 3000-3025. e.g. line 3018 below.
3018 IF BAUD = 1200 THEN RATE = 96
For standard PC serial cards, with a 1.8432MHz clock input the
divisor value RATE is given by
RATE= 115200/BAUD
To access the baud rate divisor bit 7, DLAB, of serial port register
3, the LCR register, must be set true, then the divisor value RATE
is written low byte to register 0, high byte to register 1. Finally
DLAB, bit 7 of register 3 is set false, allowing normal use of
registers 0 and 1.
3040 S1 = INP(S + 3): REM" remember parity etc.
3044 :
3050 REM" set baud rate
3052 RATELO = (RATE AND 255): REM set baud lab
3054 RATEHI = INT(RATE / 256): REM set baud lab
3058 :
3060 REM" set baud rate port
3062 OUT S + 3, S1 OR 128: REM "access dlab
3064 OUT S, RATELO: REM set baud lab
3066 OUT S + 1, RATEHI: REM set baud msb
Serial Utilities and Programming
Chapter 5 Page 63

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rs485

Table of Contents