11 of 208
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, ZX-24n, ZX-40n, ZX-44n mega644P ZX-24r, ZX-40r, ZX-44r, ZX-24s, ZX-40s, ZX-44s mega1284P ZX-1281, ZX-1281n mega1281 ZX-1280, ZX-1280n mega1280 ZX-328n, ZX-328l, ZX-32n, ZX-32l mega328P ZX-24x, ZX-32a4 xmega32A4 ZX-128a1 xmega128A1 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 C 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-24x has the same basic pinout as other 24-pin ZX devices but it operates on a maximum of 3.6 volts. Moreover, some of the special functions (USART, PWM, I2C, etc.) are on different pins as compared to the other 24-pin ZX devices. Additional information on pin assignments can be found in the ZBasic System Library Reference Manual. The ZX-40, ZX-40a, ZX-40p, ZX-40n, ZX-40r and ZX-40s 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