Navigation bar
  Start Previous page
 18 of 307 
Next page End  

ZBasic System Library
8
ZX Microcontroller Family
SPI Interface
On some ZX devices, your program is stored in an external EEPROM that is read and written using the
SPI interface.  A dedicated I/O pin is required for selecting the EEPROM device during SPI operations
and this I/O pin cannot be used for other purposes.  However, the SPI bus itself can be used to
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-24n, ZX-40n, ZX-44n
No
B.4
ZX-328n, ZX-328l
No
16, B.2
ZX-32n, ZX-32l
No
14, B.2
ZX-1281, ZX-1281n
No
10, B.0
ZX-1280, ZX-1280n
No
19, B.0
ZX-24e, ZX-24ae, ZX-24pe
Yes
24, B.4
ZX-24ne
No
24, B.4
ZX-128e, ZX-128ne, ZX-1281e, ZX-1281ne
No
28, B.0
ZX-328nu
No
13, B.2
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 purpose input if the SPI bus is used in your application.  This restriction is an
artifact of the design of the CPU’s 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
GetADC() and ADCtoCom1() use the ADC.  The analog comparator is used by WaitForInterrupt()
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
-
mega328P
Port C
-
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
Previous page Top Next page