|
Page 3 of 5
Using ZBasic
There are
essentially three steps to creating a ZBasic application and these
steps are reflected in the diagram below and are as follows: - Write and compile program
- Download program to EEPROM
- Test program and repeat

ZBasic
comes with a modern IDE that allows the programmer to produce a
multi-file project. The IDE has a built-in editor with cut and paste,
undo and program completion not found in the BasicX editor. The IDE
also acts as a front-end to the ZBasic compiler, downloader and COM
port monitor. The ZBasic compiler is of a modern design that
incorporates many advanced features including control over
optimizations. The compiler can also detect potential coding problems
such as when variables are used before they have been initialized,
unused parameters, unset function return values, and unreachable code. The
compiler can be run in a stand-alone mode or more usually from the IDE.
When compiling a ZBasic program in the IDE any errors are listed and
the line in question is highlighted. The outputs from a successful
compilation include a map file, optionally a listing file and a ZXB
file that contains the equivalent code in the ZBasic virtual machine
language. The next step is to download the program
to the 32K bytes EEPROM memory connected to the ATmega32 Serial
Peripheral Interface (SPI) bus. The IDE or a stand-alone downloader on
the PC initiates the download process and the ZBasic runtime takes care
of communications with the host PC and downloads the program into the
EEPROM memory. At this point the program is ready to be run by the
virtual machine inside the flash memory of the AVR chip. The
third step is that the virtual machine resets itself and after
initialization loads the first few bytes of the program from EEPROM
memory. The virtual machine interpreter decodes the instruction and
executes it. Further program instruction bytes or program data are
loaded from EEPROM as required. A COM port monitor on the PC can be
used to send and receive data to the ZBasic runtime via the AVR USART.
At this point the user is either testing or running the program which
is interacting with the outside world through the built-in I/O
facilities of the ATmega32 chip.
|