Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
522
/
631
Receive buffer non-empty flag bit (RNE)
When the receive buffer is not empty, the RNE flag (SPI_STS.RNE) is set to 1, so the user knows that there is data
in the receive buffer. After reading the SPI_DAT register, the hardware will set this flag to 0.
BUSY flag bit (BUSY)
When the transmission starts, the hardware sets the BUSY flag (SPI_STS.BUSY) to 1, and after the transmission
ends, the hardware sets the BUSY flag to 0.
Only when the device is in the master one-wire bidirectional receive mode, the BUSY flag (SPI_STS.BUSY) will be
set to 0 when the communication is in progress.
The BUSY flag (SPI_STS.BUSY) will be cleared to 0 in the following cases:
End of transmission (except for continuous communication in master mode);
Turn off the SPI module (SPI_CTRL1.SPIEN = 0);
The master mode error occurs (SPI_STS.MODERR = 1)
When the communication is discontinuous: the BUSY flag (SPI_STS.BUSY) is cleared to '0' between the
transmission of each data item.
When communication is continuous: in master mode, the BUSY flag (SPI_STS.BUSY) remains high during the
entire transfer process; In slave mode, the BUSY flag (SPI_STS.BUSY) will be low for 1 SPI clock cycle between
each data item transfer. So do not use the BUSY flag to handle the sending and receiving of each data item.
Disabling the SPI
In order to turn off the SPI module, different operation modes require different operation steps:
Master or slave full duplex mode
1.
Wait for the RNE flag (SPI_STS.RNE) to be set to 1 and the last byte to be received;
2.
Wait for the TE flag (SPI_STS.TE) to be set to 1;
3.
Wait for the BUSY flag (SPI_STS.BUSY) to be cleared to 0;
4.
Turn off the SPI module (SPI_CTRL1.SPIEN = 0).
Two-wire one-way send-only mode or one-wire bidirectional send mode for master or slave
1.
After writing the last byte to the SPI_DAT register, wait for the TE flag (SPI_STS.TE) to be set to 1;
2.
Wait for the BUSY flag (SPI_STS.BUSY) to be cleared to 0;
3.
Turn off the SPI module (SPI_CTRL1.SPIEN = 0).
Two-wire one-way receive-only mode or one-wire bidirectional receive mode for master
1.
Wait for the penultimate RNE (SPI_STS.RNE) to be set to 1;
2.
Before closing the SPI module (SPI_CTRL1.SPIEN = 0), wait for 1 SPI clock cycle (using software delay);
3.
Wait for the last RNE (SPI_STS.RNE) to be set before entering shutdown mode (or turning off the SPI module