![Geehy SEMICONDUCTOR APM32F030x4x6x8xC User Manual Download Page 297](http://html1.mh-extra.com/html/geehy-semiconductor/apm32f030x4x6x8xc/apm32f030x4x6x8xc_user-manual_573629297.webp)
www.geehy.com Page 296
the master and the slave are connected through two unidirectional lines MOSI
and MISO. During SPI communication, synchronous data transmission is
conducted according to SCK clock edge. The data of the master are transmitted
to the slave through MOSI pin, and the data of the slave are transmitted to the
master through MISO pin. When the data transmission is completed, it means
that the information is exchanged successfully.
23.4.4.4
Half-duplex communication of SPI
One clock line and one bidirectional data line
Enable this mode by setting BMEN bit of SPI_CTRL1 register
Control the data line to be input or output by setting BMOEN bit of
SPI_CTRL1 register
SCK pin is used as clock, MOSI pin is used in master device to
transmit data, and MISO pin is used in slave device to transmit data
23.4.4.5
Simplex communication of SPI
One clock line and one unidirectional data line (receive-only or send-only)
In this mode, SPI mode is used as receive-only or send-only.
Send-only mode:
Data are transmitted on send pin (MOSI in master mode, MISO in
slave mode)
Then the receive pin can be used as general-purpose I/O (MISO in
master mode, MOSI in slave mode)
Receive-only mode:
Turn off SPI output function by setting RXOMEN bit in SPI_CTRL1
register
Release the send pin (MOSI in master mode, MISO in slave mode)
In master mode, enable SPI to start communication, clear SPIEN bit of
SPI_CTRL1 register and receiving data can be stopped immediately,
not needing to read BSYFLG flag (always 1)
In slave mode: Pull NSS to low level, and as long as SCK is pulsed by
clock, SPI will always receive
23.4.4.6
Communication of multiple slave devices of SPI
SPI can be operated by multiple slave devices. The master device uses GPIO
pin to manage the chip selection line of the slave device, and can control two or
more independent slave devices.
The master device decides using which slave device to transmit data by pulling
down the NSS pin of the slave device.
Data Transmitting and Receiving Process in Different SPI Modes
Table 79 Run Mode of SPI
Mode
Configure
Data pin
Full duplex mode of master
device
BMEN=0
,
RXOMEN=0
MOSI sends; MISO receives
Unidirectional receiving mode
of master device
BMEN=0
,
RXOMEN=1
MOSI is not used; MISO
receives
Bidirectional transmitting mode
of master device
BMEN=1
,
BMOEN=1
MOSI sends; MISO is not used
Bidirectional receiving mode of
master device
BMEN=1
,
BMOEN=0
MOSI is not used; MISO
receives