![]() ZBasic System Library
81
ZBasic Microcontrollers
Type
Subroutine
Invocation
ControlCom(chan, rxFlowPin, txFlowPin)
ControlCom(chan, rxFlowPin, txFlowPin, flags)
Parameter
Method
Type
Description
chan
ByVal
Byte
The serial channel of interest.
rxFlowPin
ByVal
Byte
The pin to use for receive flow control.
txFlowPin
ByVal
Byte
The pin to use for transmit flow control.
flags
ByVal
Byte
Flag bits controlling the sense of the flow control lines.
Discussion
This subroutine sets a flow control pin for the receive side and/or transmit side of a serial channel. Either
or both of the second and third parameters may be zero indicating that that type of flow control is not
desired. If the fourth parameter is not specified, it defaults to the value zero indicating that the flow
control pins should be active high. If the fourth parameter is specified, the bits of its value have the
meaning given in the table below.
Flag Parameter Values
Value
Meaning
&H01
The receive flow control pin should be active low.
&H02
The transmit flow control pin should be active low.
The remaining bits are currently undefined but may be used in the future. For compatibility with new
functionality that may be added in the future, the unused bits should always be zero.
If a receive flow control pin is specified, the pin will be made an output and placed in the active state.
This indicates to the sender that the ZX is ready to accept serial data. When the channels receive queue
is nearly full (two bytes of space left), the receive flow control pin will be set to the inactive state indicating
to the sender that data transmission should be temporarily suspended. When additional space becomes
available in the receive queue (at least three bytes), the receive flow control pin will be set back to the
active state.
If a transmit flow control pin is specified, the pin will be made an input. Before sending data, the ZX will
check the state of the transmit flow control pin and, if it is at the inactive level, no data will be sent. Note
that the input is checked periodically and transmission will resume if the transmit flow control pin is in the
active state when sampled.
The current state of the flow control signals is part of the value returned by StatusCom().
It is important to note that a receive queue that is too small is likely to result in a deadlock since there will
never be enough free space to activate the flow control signal. Also, when a channel is closed the flow
control settings for the channel are cleared. For that reason, it is recommended that the call to
ControlCom() be made, if desired, some time after a channel is opened and before it is closed.
Compatibility
This subroutine is not available on ZX devices based on the mega32 (e.g. ZX-24). Moreover it is not
available in BasicX compatibility mode.
See Also
|