Start Back Next End
  
ZBasic Language Reference
124
ZBasic Microcontrollers
HWUartSpeed
HWUartSpeed <value>[,<value>]*
Default: none
This parameter is only useful with devices that support fractional baud rate generation (e.g. the ATxmega
devices), allowing you to specify one or more baud rates that your application might use.  Certain “baud
rate friendly” operating frequencies (e.g. 14.7456MHz) are integral multiples of the common UART baud
rate and thus allow standard baud rate generation with zero error.  With other operating frequencies (e.g.
1.0MHz) only a few baud rates can be achieved that fall under the generally accepted 2% error margin
unless the fractional baud rate generator is used.  The set of baud rates specified by the (possibly
multiple) instances of this parameter is used to generate a table of initialization values for your application
thus avoiding the need to perform the computationally intensive procedure for determining the fractional
baud rate setup values at run time.   If you do not specify a set of baud rates using this parameter, a
default list of standard baud rates ranging from 300 to 460800 is employed.  Use of this device parameter
is only needed if your target device is not running at a “baud rate friendly” frequency and you need to use
a non-standard baud rate.
Note that only one baud rate may be specified when using the Option DeviceParameter form; use
multiple instances to specify the set of baud rates desired.
Examples
--device-parameter=HWUartSpeed,9600,19200
Option DeviceParameter HWUartSpeed 9600
Option DeviceParameter HWUartSpeed 19200
SWUartDivisor, SWUartMinSpeed, SWUartMaxSpeed, SWUartBaseSpeed
SWUartDivisor <value>
Default: 0
SWUartMinSpeed <value>
Default: 0
SWUartMaxSpeed <value>
Default: 0
SWUartBaseSpeed <value>
Default: 0
These parameters are used to configure the software UART timer to provide the bit timing for the software
UART channels (3-6).  It is only necessary to specify values for these parameters if the software UART
channels are used.
The parameter SWUartDivisor specifies the prescaler divisor value for the software UART timer
causing the timer to run at that fraction of the main operating frequency.  This value must be chosen to
allow accurate bit timing of the software UART over the range of speeds desired and, further, to permit
suitable timer limit values over the range of baud rates intended to be used.  The timer limit value is
computed as (ClockFrequency / SWUartDivisor / (4 * base baud rate)).  This value must fall
in the range given in the table below for all possible base baud rates (as defined below).
Allowable Range of Timer Limit Values
8-bit timer (e.g. mega, tiny)
16-bit timer (e.g. xmega)
1 < timerLimit <= 256
1 < timerLimit <= 65,536
The values of the SWUartMinSpeed and SWUartMaxSpeed parameters must be in the range 300-19200
inclusively and the minimum speed must be less than or equal to the maximum speed.  For devices with
8-bit timers, the value of the SWUartBaseSpeed may be specified as greater than the minimum speed
and less than or equal to the maximum speed.
The set of base baud rates for which the timer limit value must be checked ranges from
SWUartMaxSpeed on the high end to the greater of SWUartMinSpeed and SWUartBaseSpeed (if
specified) on the low end.  Essentially, the SWUartBaseSpeed parameter provides a way to avoid
exceeding the timer limit range while still supporting the lower baud rates.  The example set of parameter
values shown below would be suitable for a target device running at 16MHz and having an 8-bit software
Previous page Top Next page