ZBasic Language Reference
121
ZBasic Microcontrollers
directive. In both instances the specification of a device parameter comprises a parameter name and a
parameter value. The next section describes the available device parameters.
The following list enumerates the available device parameters, describes the parameter values, indicates
which are required, and, when applicable, when they cannot be used. Note that neither the names nor
the values are case sensitive. The procedure for determining appropriate values for some of the device
parameters is fairly complicated (e.g. the SW UART parameters). The IDE provides a special dialog that
performs the computations given some basic operating parameters. See Section 9.6 for more details.
The target device parameters may be specified in the project file using the command line option form (--
device-parameter=name,value) or in the source code itself using the Option form (Option
DeviceParameter name value). In the latter case, the value must be specified either as a decimal
number, as an identifier (begins with a alphabetic character followed by zero or more alphanumeric
characters), or as a quoted string. Examples of both forms are given with each description below. See
Issues" for information on the effect of generic target configuration values for various ZBasic System
Library routines.
A few target device parameters can also be used with native mode ZX devices; the descriptions below
explicitly indicate if they can be.
ClockFrequency <value>
Default: none
This required parameter specifies the operating frequency of the target device (specified in Hertz). The
value of this parameter influences all of the time-dependent aspects of ZBasic routines such as serial
communication, I/O timing, delays, etc. as well as the operation of the real time clock (RTC) if it is
enabled.
Examples
--device-parameter=ClockFrequency,16000000
Option DeviceParameter ClockFrequency 16000000
ClockPrescaler <value>
Default: 1
This optional parameter, valid only for ATtiny and ATmega generic devices and native mode ZX devices,
specifies a division factor to be applied to the main clock source to achive the desired clock frequency.
The set of valid prescaler values is 1, 2, 4, 8, 16, 32, 64, 128 and 256. A device with a 16MHz crystal and
a prescaler value of 2 will operate at 8MHz.
It is important to note that the maximum baud rate for the software serial channels is reduced in direct
proportion to the clock prescaler. For example, on a ZX-24n using a prescaler value of 2 results in a
maximum baud rate of 9600 as compared to the standard 19.2K baud. For ZX devices, the largest
prescaler value allowed is the one that reduces the operating frequency to no lower than 230.4KHz.
Examples
--device-parameter=ClockPrescaler,2
Option DeviceParameter ClockPrescaler 2
|