8
communicate with other SPI devices. Although most SPI devices are tolerant of the ZX device using the
SPI bus to fetch instructions from your program, a few are not. Generally speaking, if you can send and
receive all of the data that an SPI device requires using a single call to SPICmd(), then that SPI device is
usable with the ZX models that utilize an external EEPROM. The table below indicates which devices
use an external EEPROM for user programs and, if so, the I/O pin used for the chip select.
SPI Channel and EEPROM Usage
ZX Model
Uses SPI EEPROM
SPI CS Pin
ZX-24, ZX-24a, ZX-24p
Yes
B.4
ZX-40, ZX-40a, ZX-40p
Yes
5, B.4
ZX-44, ZX-44a, ZX-44p
Yes
44, B.4
ZX-24e, ZX-24ae
Yes
24, B.4
ZX-24n, ZX-40n, ZX-44n
No
10, B.0
ZX-1281, ZX-1281n
No
10, B.0
ZX-1280, ZX-1280n
No
19, B.0
ZX-128e, ZX-1281e
No
28, B.0
It is important to note that even for the devices that do not use the external SPI EEPROM, the SPI CS pin
cannot be used as a general input if the SPI bus is used in your application. This restriction is an artifact
of the design of the CPUs SPI controller. The SPI CS pin can, however, be used as a general purpose
output.
Analog-to-Digital Converters
Most ZX devices support up to 8 analog inputs. These inputs may be fed to the internal analog-to-digital
converter (ADC) or they may be used to perform analog level comparisons. The I/O port containing the
analog inputs varies by ZX device as indicated in the table below. The System Library routines
when configured to await an analog comparator event.
Analog Input Ports by CPU Type
Underlying CPU Type
Analog Port 1
Analog Port 2
mega32, mega644, mega644P
Port A
-
mega128, mega1281
Port F
-
mega1280
Port F
Port K
Interrupts
Some of the System Library routines disable interrupts in order to achieve the precise timing that is
required. Having interrupts disabled for long periods of time can interfere with the operation of other parts
of the system that use interrupts like task management, serial I/O and the real time clock. In most cases,
the System Library routines have been implemented to keep track of real time clock interrupts that should
have occurred during the time interrupts are disabled and then the RTC is updated at the end of the
operation. This strategy avoids the problem of the RTC losing time.
Unfortunately, there is no way to similarly protect the serial I/O process. You can reduce the impact of
having interrupts disabled with respect to serial output by ensuring that all serial output queues are empty
before calling a System Library routine that disables interrupts. This is not as critical for a hardware-
based serial channel (e.g. Com1) as it is for the software-based serial channels Com3 to Com6. There is
no way, however, to work around the problem of serial input data arriving while interrupts are disabled.
The hardware-based serial channels will store one received character and hold it while interrupts are
disabled but if a second character arrives while interrupts are disabled it will be lost. Channels 3-6 rely on
interrupts for every bit received so the situation is much more problematic. In this case, having interrupts
disabled for longer than approximately one-third of the bit time will likely cause garbled input if a
characters transmit time overlaps the period when interrupts are disabled. For characters being
transmitted by channels 3-6, having interrupts disabled for more than about 10% of the bit time may
cause the receiver to lose synchronization.