Navigation bar
  Start Previous page
 168 of 286 
Next page End  

154
OpenSPISlave
Type
Subroutine
Invocation
OpenSPISlave(flags)
Parameter
Method
Type
Description
flags
ByVal
Byte
Flags controlling the SPI communication.
Discussion
This subroutine, available only for native mode devices, immediately activates the SPI interface in slave
mode.  The flags parameter specifies the characteristics of the SPI communication.  They must be set
to be compatible with the SPI master with which you want to communicate.  See the table below for
details.  
SPI Slave Mode Configuration Bits
Function
Hex Value
Bit Mask
Clock Phase False
&H00
xx xx x0 xx
Clock Phase True
&H04
xx xx x1 xx
Clock Low at Idle
&H00
xx xx 0x xx
Clock High at Idle
&H08
xx xx 1x xx
Bit Order – MSB first
&H00
xx 0x xx xx
Bit Order – LSB first
&H20
xx 1x xx xx
The chip select pin for an SPI slave is a dedicated pin; see the table below.  If you activate slave mode,
you must also provide an interrupt handler for the SPI_STC vector.  While slave mode is active,
SPICmd() calls are ineffective.  Slave mode can be canceled by calling CloseSPI().
Slave Mode CS Pin
ZX Models
CS Pin
ZX-40n
5, B.4
ZX-44n
44, B.4
ZX-24ne
24, B.4
ZX-1281n
10, B.0
ZX-1280n
19, B.0
ZX-128ne, ZX-1281ne
28, B.0
Note that the SPI master sets the SPI clock speed.  The highest SPI clock speed that can be used
reliably is one quarter of the CPU clock speed of a ZX slave device.  Depending on how much
computation the slave must perform to prepare data for sending back to the master, a substantially slower
SPI clock may need to be used.  If a ZX device is being used as the master, it may be useful to set the
rxDelay parameter on calls to OpenSPI() on the master to allow additional processing time.
Compatibility
This subroutine is only supported for native mode devices.
See Also
Previous page Top Next page