SC5313A Operating & Programming Manual
Rev 1.0.2
31
Writing the SPI Bus
The SPI transfer size (in bytes) depends on the register being targeted. The MSB byte is the command
register address as noted in Table 8. The subsequent bytes contain the data associated with the register.
As data from the host is being transferred to the device, data present on its SPI output buffer is
simultaneously transferred back, MSB first, via the master-in-slave-out (MISO) line. The data return is
invalid for most transfers except for those register commands querying for data from the device. See
“Reading the SPI Bus” section for more information on retrieving data from the device. Figure 6 shows
the contents of a single 3 byte SPI command written to the device. Table 4 provides information on the
number of data bytes and their contents for an associated register. There is a minimum of 1 data byte
for each register even if the data contents are “zeros”.
Figure 6. Single 3 byte transfer buffer.
Reading the SPI Bus
Data is simultaneously read back during a SPI transfer cycle. Requested data from a prior command (see
Table 9) is available on the device SPI output buffers, and these are transferred back to the user host via
the MISO line. To obtain valid requested data would require querying the SPI_OUT_BUFFER, which
requires 5 bytes of clock cycles; 1 byte for the device register (0x22) and 4 empty bytes (MOSI) to clock
out the returned data (MISO). An example of reading the temperature from the device is shown in
Figure 7.
Figure 7. Reading queried data.
In the above example, valid data is present in the last 2 bytes; byte 1 and byte 0. Table 9 shows the valid
data bytes associated with the querying register.
Table 9. Valid returned data bytes.
Register Name
Register
Address
Byte 3
Byte 2
Byte 1
Byte 0
GET_TEMPERATURE
0x20
valid
valid
GET_DEVICE_STATUS
0x21
valid
USER_EEPROM_READ
0x23
valid
CAL_EEPROM_READ
0x24
valid
23
15
7
0
Register Address
Byte 1
Byte 0
0x00
0x21
Invalid
Invalid
CLK
MOSI
CS
MISO
0x00
0x00
Data Byte 3
Invalid
Data Byte 2
0x22
Request for temperature
Query SPI_OUTPUT_BUFFER for data
0x00
0x00
Data Byte 1
Data Byte 0