USB-ISS Multifunction USB Communications Module
SPI Mode - Technical Specification
In SPI mode the USB-ISS is always the master and supplies the
SCK signal, and always returns the same number of bytes as you send.
The format is simple:
Send | SPI command (0x61) | TxData1 | TxData2 | TxData3 | ... | TxData n |
Receive | ACK (0xFF) or NACK (0x00) | RxData1 | RxData2 | RxData3 | ... | RxData n |
All bytes should be sent to the USB-ISS in one sequence. A gap will result in the USB-ISS re-starting its internal command synchronization loop and ignoring the message. The maximum frame length including the command is 63 bytes.
Here is an example of using SPI mode to communicate with
Microchip's SPI SRAM, the 23k256.
Make sure you have the power link removed so
you are working at 3.3v, as the 23k256 does not work at 5v.
The power up default of the 23k256 is byte mode. Here we will change this to sequential mode so any number of bytes can be read/written in the same frame. To do that we write to the status register. The command is:
Send | SPI command (0x61) | 0x01 | 0x41 |
Receive | ACK (0xFF) or NACK (0x00) | 0xnn | 0xnn |
This is a 3 byte command. The 0x01 is the 23k256's "write status register" command. 0x41 is the new status register value. It puts the device into sequential mode and disables the hold. You must read back the same number of bytes as you send, in this case three. Only the first byte contains useful information. 0xnn are "don't care" bytes.
Next we will write four bytes to the SRAM.
Send | SPI command (0x61) | 0x02 | 0x00 | 0x00 | 0x12 | 0x34 | 0x56 | 0x78 |
Receive | ACK (0xFF) or NACK (0x00) | 0xnn | 0xnn | 0xnn | 0xnn | 0xnn | 0xnn | 0xnn |
Here we follow the SPI command with 0x02 which is the 23k256's write command. The next two 0x00's are the address high and address low of the SRAM address. These are followed by the four data bytes, in this case 0x12, 0x34, 0x56, 0x78.
To read back the same bytes you would do this:
Send | SPI command (0x61) | 0x03 | 0x00 | 0x00 | 0xnn | 0xnn | 0xnn | 0xnn |
Receive | ACK (0xFF) or NACK (0x00) | 0xnn | 0xnn | 0xnn | 0x12 | 0x34 | 0x56 | 0x78 |
The 0x03 is the 23k256's read command followed by the address (0x0000). We can then send any four bytes to clock the data out of the SRAM.