17 of 323
ZBasic System Library 7 ZX Microcontroller Family Resource Usage The AVR devices on which the ZX microcontrollers are based offer a variety of resources for use in your program, e.g. timers, interrupts, USART (hardware serial port), analog-to-digital converters, etc. Some of these resources are allocated to specific functions of the ZX microcontroller and/or are used by certain ZBasic System Library routines. The resources available on a particular ZX device vary depending on the particular CPU upon which the device is based. The table below indicates the underlying CPU for the various ZX devices. The remainder of this section provides an overview of resource allocation for ZX devices. Underlying CPU Type for ZX Devices ZX Model CPU Type ZX-24, ZX-40, ZX-44, ZX-24e mega32 ZX-24a, ZX-40a, ZX-44a, ZX-24ae mega644 ZX-24p, ZX-40p, ZX-44p, ZX-24n, ZX-40n, ZX-44n, ZX-24ne, ZX-24pe, ZX-24nu, ZX-24pu mega644P ZX-24r, ZX-40r, ZX-44r, ZX-24s, ZX-40s, ZX-44s, ZX-24ru, ZX-24su mega1284P ZX-328n, ZX-328l, ZX-32n, ZX-32l, ZX-328nu mega328P ZX-1280, ZX-1280n mega1280 ZX-1281, ZX-1281n, ZX-1281e, ZX-1281ne mega1281 ZX-128e, ZX-128ne mega128 ZX-128a1 xmega128A1 ZX-24x, ZX-32a4, ZX-24xu xmega32A4 USART An on-board hardware serial port, or USART, is used for the Com1 serial channel. By default, the USART is configured to operate at 19,200 baud and is utilized by the System Library Routines Console.Read, Console.ReadLine, Console.Write, Console.WriteLine and Debug.Print. You may reconfigure the USART to a different speed by using the System Library routine OpenCom, specifying channel 1. The USART is also used for the ADCtoCom1 and Com1toDAC routines. In both of these cases, the Com1 speed is automatically configured. Some ZX devices have more than one hardware USART. In these cases, one of the USARTs is assigned to the Com1 serial channel, another USART is assigned to the Com2 serial channel, etc. as shown in the table below. The effect of these assignments is generally only important with respect to which I/O pins are available for other purposes if the additional hardware USARTs are not being used. It also will be important if your program manipulates the USART registers directly. Hardware USART Channel Assignment and I/O Pin Usage ZX Model USART Serial Channel Tx Pin Rx Pin ZX-24, ZX-24a USART0 Com1¹ 1, D.1 2, D.0 ZX-24p, ZX-24n, ZX-24r, ZX-24s USART0 Com1¹ 1, D.1 2, D.0 USART1 Com2 11, D.3 6, D.2 ZX-40, ZX-40a USART0 Com1 15, D.1 14, D.0 ZX-40p, ZX-40n, ZX-40r, ZX-40s USART0 Com1 15, D.1 14, D.0 USART1 Com2 17, D.3 16, D.2 ZX-44, ZX-44a USART0 Com1 10, D.1 9, D.0 ZX-44p, ZX-44n, ZX-44r, ZX-44s USART0 Com1 10, D.1 9, D.0 USART1 Com2 12, D.3 11, D.2 ZX-328n, ZX-328l USART0 Com1 3, D.1 2, D.0 ZX-32n, ZX-32l USART0 Com1 31, D.1 30, D.0 ZX-1281 USART1 Com1 28, D.3 27, D.2 USART0 Com2 3, E.1 2, E.0 ZX-1280 USART0 Com1 3, E.1 2, E.0 USART1 Com2 46, D.3 45, D.2 USART2 Com7 13, H.1 12, H.0