AT32F425
Series Reference Manual
2022.03.30
Page 165
Ver 2.01
Figure 13-5 Single-wire bidirectional half -duplex mode
SPI master
SCK
MISO
MOSI
CS
SPI slave
SCK
MISO
MOSI
CS
When the SPI is selected for data transmission in single-wire bidirectional half-duplex mode (master or
slave), the TDBE bit must be set, and the BF must be 0 before disabling the SPI. The power-saving
mode (or disabling SPI system clock) cannot be entered unless the SPI is disabled.
In master mode, when the SPI is selected for data reception in single-wire bidirectional half-duplex mode,
it is required to wait until the second-to-last RDBF is set and then another SPI_SCK period before
disabling the SPI. And the last RDBF must be set before entering power-saving mode (or disabling SPI
system clock).
In slave mode, when the SPI is selected for data reception in single-wire bidirectional half-duplex mode,
there is no need to check any flags before disabling the SPI. However, the BT must be 0 before entering
power-saving mode (or disabling SPI system clock).
13.2.3 Chip select controller
The Chip select controller (CS) is used to enable hardware or software control for chip select signals
through software configuration. This controller is used to select master/slave device in multi-processor
mode, and to avoid conflicts on the data lines by enabling the SCK signal output followed by CS signal.
The hardware and software configuration procedure is detailed as follows, along with their respective
input/output in master and slave mode.
CS hardware configuration procedure:
In master mode with CS being as an output, HWCSOE=1, SWCSEN=0, the CS hardware control is
enabled. If the SPI is enabled, low level is output on the CS pin. The CS signal is then released after the
SPI is disabled and the transmission is complete.
In master mode with CS being as an input, HWCSOE=0, SWCSEN=0, the CS hardware control is
enabled. At this point, the SPI is automatically disabled by hardware and enters slave mode as soon as
the CS pin low is detected by master SPI. The mode error flag (MMERR bit) is set at the same time. An
interrupt is generated if ERRIE=1. When the MMERR is set, the SPIEN and MSTEN cannot be set by
software. The MMERR is cleared by read or write access to the SPI_STS register followed by write
operation to the SPI_CTRL1 register.
In slave mode with CS being as an input, HWCSOE=0, SWCSEN=0, the CS hardware control is enabled.
The slave selects whether to transmit / receive data based on the level on the CS pin. The slave is
selected for data reception and transmission only when the CS pin is low.
CS software configuration procedure:
In master mode with CS being as an input, SWCSEN=1, the CS software control is enabled. When
SWCSIL=0, the SPI is automatically disabled by hardware and enters slave mode. The mode error flag
(MMERR bit) is set at this time. An interrupt is generated if ERRIE=1. When the MMERR bit is set, the
SPIEN and MSTEN bits cannot be set by software. The MMERR bit is cleared by read or write access
to the SPI_STS register followed by write operation to the SPI_CTRL1 register.
In slave mode with CS being as an input, SWCSEN=1, the CS software control is enabled. The SPI
judges the CS signal with the SWCSIL bit, instead of CS pin. When SWCSIL=0, the slave is selected for
data reception and transmission.