ZBasic Language Reference
147
ZBasic Microcontrollers
command mode (either automatically, or by way of the ZBasic System Library subroutine ZXCmdMode).
Once in command mode, the downloader can optionally send a command to instruct the device to switch
to 115.2K baud for the download; otherwise the downloading is done at the prevailing baud rate. Finally,
once the download has completed, the downloader sends a command telling the device to reset thus
commencing execution of the downloaded program.
The ATN character is set in the ZBasic IDE using the dialog invoked by choosing the Serial Port Options
entry on the Options menu. In the Download Options groupbox, youll find a checkbox captioned Use
ATN character. When that checkbox is checked, two more controls become enabled. The first is an edit
box with an accompanying spin control that allows you to specify the desired ATN character (the range
for which is 1 to 31 decimal). Below the enabling checkbox, another checkbox captioned Change speed
for download allows you to control whether the download is done at the prevailing speed (unchecked) or
at 115.2K baud (checked). If you are using a serial channel that does not support dynamically changing
the baud rate, you should uncheck the latter checkbox.
On the ZBasic device side, enabling downloading by way of the ATN character can be accomplished in
one of two ways. The simplest way is to use the directive Option AtnChar in the first module of your
program. Once your program is compiled and downloaded (which, by the way, must be initially
accomplished using the traditional DTR-based method), when the device receives the designated ATN
character it will automatically invoke the command mode. The second method, which should rarely be
needed, is to add code to your application to detect the specified ATN character. When the ATN
character is received, your code should invoke the ZBasic System Library subroutine ZXCmdMode()
either with no parameter or with a parameter value of False.
It is important to note that the Port Speed setting in the Execution Options group box must be set to
match the baud rate of the Com1 serial channel of the ZBasic device. The default Com1 speed is 19.2K
baud but the speed can be changed using the directive Option Com1Speed in the first module of your
program.
9.9 Updating Device Firmware
The VM-mode ZX devices have firmware that 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 a VM-mode ZX using the Device Options... entry on the Options menu. This
will bring up a dialog that will allow you to navigate to and select the specially formatted firmware update
file (typically with .zvm extension). Prior to using the files contents to update the ZX firmware, the file is
checked to ensure that it contains a valid update image. Note, particularly, that separate update files are
provided for each ZX model. You must be certain that you use the correct update file for the ZX device
being updated. The filenames of the update files indicate the target ZX device and the firmware version
number. Additionally, the first few lines of the update file contain the same information. The update files
are standard text files and may be viewed by any text file viewer.
To perform a normal firmware update the ZX must be powered up and must be connected to your PC by
a serial cable. 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 those pins that would be
adversely affected by the LEDs being activated you will want to turn off the check box labeled Provide
visual feedback during update.
On the other ZX devices no I/O pins are used to indicate that a firmware update is in progress.
9.10 Setting the Debug Output Limit
By default, the debug window will only retain the last 100 lines of output. You can change this by
selecting the Open User Options File entry from the Options menu. This will display the current
contents, if any, of the User Options File. If one does not exist you may insert a line like the one below.
debug.line.limit=250
|