Start Back Next End
  
ZBasic System Library
304
ZBasic Microcontrollers
SPIStart
Type
Subroutine
Invocation
SPIStart(channel, flags)
Parameter
Method
Type
Description
channel
ByVal
Byte
The SPI channel number (1-4).
flags
ByVal
Byte
Flag bits indicating actions to take (see discussion).
Discussion
If the specified channel is valid and is open, this subroutine modifies the state of the SPI interface
according to the bits that are on in the flags parameter as described below.  If multiple bits are on in the
flags parameter they are processed in order from least significant to most significant.
Flag Parameter Action Bits
Hex Value
Binary Value
Description
&H01
xx xx xx x1
Initialize the SPI controller associated with the channel (ignored for a
software channel).
&H02
xx xx xx 1x
Deassert the chip select pin associated with the channel.
&H04
xx xx xx1 xx
Assert the chip select pin associated with the channel.
For compatiblility with future enhancements the unused bits in the flags parameter should always be zero. 
Note that this is a low level routine that must be used in concert with other low level routines to effect an
SPI bus transaction.
If this routine is called with bits 1 and 2 both on (i.e. &H06) when the chip select is already asserted, the
result will be that the chip select is deasserted for about 150 CPU cycles (~10uS at 14.7MHz) and then
reasserted.  This idiom is useful for terminating one SPI cycle and immediately beginning another.
Example
Call OpenSPI(1, 0, 12)
Call SPIStart(1, &H05)
Compatibility
This routine is not available in BasicX compatibility mode nor it is available for VM devices.
See Also
Previous page Top Next page