Navigation bar
  Start Previous page
 157 of 283 
Next page End 152 153 154 155 156 157 158 159 160 161 162  

148
OpenCom
Type
Subroutine
Invocation
OpenCom(channel, baud, inQueue, outQueue)
Parameter
Method
Type
Description
channel
ByVal
Byte
The serial channel to open.
baud
ByVal
Long
The desired baud rate.
inQueue
ByRef
array of Byte
The queue for incoming characters.
outQueue
ByRef
array of Byte
The queue for outgoing characters.
Discussion
This subroutine prepares a serial channel for use.  If the specified channel is already open or if the
channel number is invalid, it has no effect.  The supported channel numbers are 1, 2 and 3-6 but you
must have previously called ComChannels() in order to use channels 4-6.
The supported baud rates for Com1 (channel 1) and Com2 are the standard rates from 300 to 460,800
while the supported rates for Com3 to Com6 (channels 3-6) range from 300 to 19,200.  However, if
ComChannels() has been invoked, the maximum rate for channels 3-6 will be limited to that specified in
the description of ComChannels().  Moreover, for channels 3-6 the baud rate for any given channel
must be an integral divisor of the maximum rate.
The queues specified for the receive and transmit channels each must have been previously initialized by
calling OpenQueue().  If you set up a transmit-only or receive-only serial channel you may use the value
0 for the unused queue.  If you provide the value 0 for both queues, the channel will not be opened.
Example
Dim outQueue(1 to 40) as Byte
Call OpenQueue(outQueue, SizeOf(outQueue))
Call ComChannels(2, 9600)
Call DefineCom(4, 0, 12, &H08)
Call OpenCom(4, 9600, 0, outQueue)
The code above prepares Com4 as a transmit-only serial channel.  If you wanted reception as well, you
would have to declare and initialize a second queue and define the receive pin.
Resource Usage
The hardware UARTs are assigned to channel numbers as shown in the table below.
Hardware UART Assignment
ZX Model
Com1
Com2
Com7
Com8
ZX-24, ZX40, ZX-44, ZX-24e
USART0
-
-
-
ZX-24a, ZX40a, ZX-44a, ZX-24ae
USART0
-
-
-
ZX-24p, ZX-40p, ZX-44p
USART0
USART1
-
-
ZX-24n, ZX-40n, ZX-44n
USART0
USART1
-
-
ZX-1281, ZX-1281n
USART1
USART0
-
-
ZX-1280, ZX-1280n
USART0
USART1
USART2
USART3
ZX-128e, ZX-1281e
USART0
USART1
-
-
Previous page Top Next page