ZBasic Language Reference
164
ZBasic Microcontrollers
Download the file test.zxb using the default COM port, go to monitor mode until character code 8 is
received.
zload s0x08 m test.zxb
Download using the ATN character &H14 at 57.6K baud on COM2, constant speed (no speed change).
zload c2:57600 A0x14
Download to a generic mega-based target device running at 16MHz using 19200 baud for both
downloading and running after the download.
zload c2 dmega f16000000 b19200:19200 m test.zxb
Perform ATN testing using COM2.
zload c2 a
The default serial port may be specified by setting an environment variable named ZLOAD_PORT. The
value of this environment variable should be a series of decimal digits specifying the serial port number
(1-99). The method used to set an environment variable varies depending on the operating system.
Consult your OS documentation for more information.
Example
ZLOAD_PORT=2
If no default serial port is specified and the c option is not specified, COM1 is used by default.
Source code is provided in the distribution for the zload utility. It is a fairly simple program written in C
and C++ targeted to the Windows platform. The utility may be able to be ported to another operating
system by a skilled programmer who is familiar with programming for both Windows and the target
platform.
11.1 Firmware Updates
The firmware of VM-mode ZX devices (as opposed to native mode ZX devices) is designed to be field-
upgradeable. This allows the control program to be updated with newer versions as enhancements are
made and problems are fixed. An update can be installed in the ZX using the u option of the zload
command line utility and specifying the name of a file to install. The file must contain specially formatted
data, the integrity of which is verified before downloading to the ZX. It is important to note that the
separate update files are provided for the various models. Be sure that you have the correct update file
for your ZX device.
To perform a normal firmware update the ZX must be powered up and must be connected to your PC by
a serial cable. An example invocation of zload to perform a normal firmware update is shown below. The
example shows the use of the -c option to also specify the serial port to use. The file zx24_1-10-
2.zvm is an example of the specially formatted update file for the ZX-24.
zload c2 u zx24_1-10-2.zvm
On the 24-pin ZX devices, during the update process the red LED will be illuminated continuously and the
green LED will blink at a rate of about twice per second. Note that since the LEDs are also connected to
pins 25 and 26, if you have circuitry connected to these pins that would be adversely affected by the
LEDs being activated you can suppress the activation of the LEDs by using the U option to instead of
using u.
It is important to ensure that the update process, once begun, is allowed to run to completion. Powering
down the ZX or resetting it during the update may leave it in an unusable state. It is possible that the ZX
may no longer be able to properly interact with the zload program to effect a subsequent complete
update. In such a case, you may be able to use the special emergency update procedure described
below.
|