175
CHAPTER 5 PERIPHERAL HARDWARE FUNCTIONS
(b) Explanation of commands
(i) Types of commands
This example uses the following commands:
<1> READ command : Transfers data from slave to master.
<2> WRITE command : Transfers data from master to slave.
<3> END command : Informs slave of WRITE command completion.
<4> STOP command : Informs slave of WRITE command interruption.
<5> STATUS command : Reads slave status.
<6> RESET command : Sets currently selected slave as non-selected slave.
<7> CHGMST command: Passes master authority to slave.
(ii) Protocol
The following protocol is used for communication between the master and slaves.
<1> The address of a slave with which the master intends to communicate is transmitted to select
the slave (chip select). This starts communication.
The slave that has received the address returns ACK to engage in communication with the
master (The state of the slave is changed from the non-selected state to selected state).
<2> Commands and data are transferred between the master and the slave selected in <1>.
Command and data are transferred between the master and the selected slave on a one-
to-one basis, so the other slaves must be placed in the non-selected state.
<3> Communication is completed when the selected slave is placed in the non-selected state.
This state is caused in the following cases:
The selected slave is placed in the non-selected state when the slave receives a RESET
command from the master.
The device that is switched from the master to a slave with a CHGMST command is placed
in the non-selected state.
(iii) Command format
The transfer format of each command is described below.
<1> READ command
The READ command reads data from a slave. One to 256 bytes of data can be read. The
data length is specified in a parameter by the master. When 00H is specified as the data
length, the 256-byte data transfer is assumed.
Figure 5-72. Transfer Format of the READ Command
Remark M: Output by the master
S: Output by the slave
READ
M
ACK
S
Data count
M
Data
ACK
S
Data 0
S
Data
ACK
S
Data N
S
Data
ACK
S
Command