Navigation bar
  Start Previous page
 61 of 323 
Next page End  

ZBasic System Library
51
ZX Microcontroller Family
ComChannels
Type
Subroutine
Invocation
ComChannels(count, maxSpeed)
Parameter
Method
Type
Description
count
ByVal
Byte
The total desired number of software-derived serial channels.
maxSpeed
ByVal
int8/16
The desired maximum baud rate to be supported.
Discussion
In addition to the serial channel implemented in hardware on the processor (Com1), the system can
support up to four additional serial communication channels that are implemented in the system software. 
The software-based serial channels are numbered Com3 through Com6.  However, by default, only one
additional channel, Com3, is supported.  If you want to use serial channels 4 through 6 you must call this
subroutine first to specify the maximum number (up to 4) that you want to have available.  This subroutine
must be called only when there are no open software-based serial channels (COM3 through COM6).  If it
is called when one or more channels are already open, it will have no effect.
After ComChannels() has been invoked, the serial channels that will be available depends on the value
specified by the count parameter.  If the value 2 is specified, for example, channels Com3 and Com4 will
be available.  If the maximum value of 4 is specified, then serial channels 3, 4, 5 and 6 will be available. 
Once the number of software-based serial channels has been established you may then use
DefineCom(), OpenCom(), and CloseCom() to manage the available channels by specifying the
appropriate channel number in those calls.
In addition to specifying the total number of software-based serial channels that you want, you must also
specify the maximum baud rate that you wish to utilize.  The supported rates are 300, 600, 1200, 2400,
4800, 9600 and 19,200 baud but see below for additional discussion about the maximum baud.
Because the COM3 to COM6 serial channels are implemented in software, when one or more of the
channels is open there will be a certain amount of processing overhead that will reduce the speed at
which program instructions will be executed.  Moreover, the processing overhead is higher when
supporting higher baud rates as compared to lower baud rates and the overhead is higher when
supporting a larger number of channels.  It is prudent, therefore, to choose the lowest baud rate and
lowest number of channels that is practical for your circumstances.
Also note that when supporting two or more channels, there is a small possibility that incoming characters
might not be properly recognized at the highest rate.  The probability of not being able to properly
synchronize on the incoming character’s start bit increases with each additional channel that is supported. 
For this reason, it is recommended that the maximum baud rate be limited to 9600 when configured for 2
or more channels.  
For devices operating at 7.37MHz, the number of software-implemented serial channels should be limited
to two and the maximum speed should be limited to 9600 baud.
Resource Usage
The software-implemented serial channels utilize the Serial Timer for the bit rate timing.  No other use of
the Serial Timer should be attempted when serial channels 3-6 are open.  The “Busy” flag for the timer
used to implement the software serial channels will be set to True when one or more of the software-
implemented serial channels is open.
Previous page Top Next page