Navigation bar
  Start Previous page
 75 of 283 
Next page End 70 71 72 73 74 75 76 77 78 79 80  

66
DefineCom
Type
Subroutine
Invocation
DefineCom(channel, rxPin, txPin, flags)
DefineCom(channel, rxPin, txPin, flags, stopBits)
Parameter
Method
Type
Description
channel
ByVal
Byte
The serial channel being defined.
rxPin
ByVal
Byte
The pin which will serve as the receive line.
txPin
ByVal
Byte
The pin which will serve as the transmit line.
flags
ByVal
Byte
Configuration flags.  See the discussion below.
stopBits
ByVal
Byte
The desired number of stop bits.
Discussion
channel is already open, this routine does nothing.  Likewise, there is no effect if the specified channel is
invalid (see the ComChannels() routine) or if either of the rxPin and txPin parameters are invalid or
both are zero.  Note that either rxPin or txPin may be zero, allowing you to define a transmit-only or
receive-only serial channel.
If the specified channel is a hardware UART (e.g. Com1), the rxPin and txPin parmeters must both be
zero.  Otherwise, if they are valid, the pins specified by rxPin and txPin are automatically configured as
input and output, respectively.
The flags parameter contains several bit fields used to specify some of the details of the operation of
the serial channel.
Serial Channel Configuration Flag Values
Function
Hex Value
Bit Mask
Inverted Logic¹
&H80
1x xx xx xx
Non-inverted Logic
&H00
0x xx xx xx
Ignore Parity Bit
&H40
x1 xx xx xx
Even Parity
&H30
xx 11 xx xx
Odd Parity
&H20
xx 10 xx xx
No Parity
&H00
xx 00 xx xx
7-bit Data
&H07
xx xx 01 11
8-bit Data
&H08
xx xx 10 00
   ¹ Applicable only to software-based channels (3-6).
The remaining bits are currently undefined but may be employed in the future.
When Non-inverted Logic is selected, the idle state of the transmit line will be logic 1.  When a character
transmission is begun, a “start bit” of logic zero will be sent for one bit time (the inverse of the baud rate). 
Next the data bits are sent, each for one bit time, beginning with the least significant bit and continuing
through the eighth data bit or parity bit as the case may be.  Finally, one or more “stop bits” of logic one
are sent, each for one bit time.  With Inverted Logic, each of these elements is complemented – the idle
state of the transmit line is logic 0.
Whether you should choose the Inverted or Non-inverted mode depends on the device that you intend to
communicate with and how many, if any, level converters exist between the two devices.  Typically, if the
other device is capable of sending and receiving TTL-level serial data, you’ll likely choose Non-inverted
Logic.
Previous page Top Next page