10 of 172
ZBasic Language Reference 3 ZX Microcontroller Family A subroutine is invoked by using the Call statement that specifies the name of the subroutine to invoke and, optionally, the parameters to pass to the subroutine. A function is invoked by using its name in place of a value (directly or in an expression) and specifying the parameters, if any, that are to be passed to the function. This concludes a rather brief introduction to the ZBasic language. The remaining sections of this manual describe in more detail the various elements of ZBasic including data types, variables, constants, statements, subroutines and functions. Also, more advanced topics like multi-tasking, queues, serial communications and others are presented. 1.1 The ZBasic System Library The ZBasic System Library provides a rich collection of over 150 subroutines and functions that you can use to quickly add functionality to your application. The routines fall into several fundamental categories including mathematical functions, string-oriented routines, I/O-related routines, type conversion functions, etc. The routines are fully documented in the ZBasic System Library Reference Manual. 1.2 The ZX Microcontroller Family The ZBasic language was designed to be well suited for programming microcontrollers. It is based on a subset of Microsoft’s popular Visual Basic (VB6) with modifications and extensions to address the special needs of microcontroller programming. The ZX- series microcontrollers were designed to run ZBasic programs efficiently. At the time of publication, the ZX- series devices available from Elba Corp. include several models with different capabilities, based on several different CPU types as shown in the table below. The various ZX devices will be referred to collectively in this document as simply ZX unless the context requires a specific reference to a particular model. Underlying CPU Type for ZX Devices Device CPU ZX-24, ZX-40, ZX-44 mega32 ZX-24a, ZX-40a, ZX-44a mega644 ZX-24p, ZX-40p, ZX-44p mega644P ZX-24n, ZX-40n, ZX-44n mega644P ZX-1281, ZX-1281n mega1281 ZX-1280, ZX-1280n mega1280 ZX-328n, ZX-328l, ZX-32n, ZX-32l mega328P The ZX-24, ZX-24a, ZX-24p and ZX-24n are 24-pin DIP format modules that are pin-compatible with the Parallax Basic Stamp and the NetMedia BX-24 microcontrollers. However, many improvements have been made with respect to those pioneering products in order to provide a more powerful and flexible programming platform. Because of its ready-to-use configuration it is an ideal starting point for someone just beginning to use microcontrollers. Yet, it has enough powerful capabilities for experts and advanced users as well. See Appendix B for more detailed information on the ZX-24 series devices including several suggested connection diagrams and detailed descriptions of the function of each pin. The ZX-40, ZX-40a, ZX-40p and ZX-40n are 40-pin DIP format integrated circuits that are pre- programmed with the ZX control program. However, in order to use them you must add a few external components such as a regulated supply, a crystal, a memory chip and serial interface circuitry. The compensating advantages of the ZX-40/ZX-40a are reduced cost, more design flexibility and availability of more I/O pins. These attributes make the 40-pin ZX well-suited for advanced projects and commercial applications. See Appendix C for more detailed information on the ZX-40/ZX-40a including several suggested connection diagrams. The ZX-44, ZX-44a, ZX-44p and ZX-44n are 44-pin TQFP format integrated circuits that are pre- programmed with the ZX control program. Similarly, the ZX-1280 and ZX-1281 are 100-pin and 64-pin, respectively, TQFP format integrated circuits that are pre-programmed with the ZX control program. All of these devices are bare CPUs that require some additional support components. Because of their smaller size, they are well suited for larger volume applications or those that require compact size. See Appendix