26.3.2.1.2 Buffer Mode
The Buffer mode is enabled by writing the BUFEN bit in the SPIn.CTRLB register
to ‘
1
’. The BUFWR bit in SPIn.CTRLB has no effect in Master mode. In
Buffer mode, the system is double-buffered in the transmit direction and triple-buffered in
the receive direction. This influences the data handling the following ways: - New bytes can be written to the DATA register (SPIn.DATA) as long as the Data Register Empty Interrupt Flag (DREIF) in the Interrupt Flag Register (SPIn.INTFLAGS) is set. The first write will be transmitted right away, and the following write will go to the Transmit Data Buffer register.
- A received byte is placed in a two-entry Receive First-In, First-Out (RX FIFO) queue comprised of the Receive Data register and Receive Data Buffer immediately after the transmission is completed.
- The DATA register is used to read from the RX FIFO. The RX FIFO must be read at least every second transfer to avoid any loss of data.
When both the shift register and the Transmit Data Buffer register become empty, the Transfer Complete Interrupt Flag (TXCIF) in the Interrupt Flags register (SPIn.INTFLAGS) will be set. This will cause the corresponding interrupt to be executed if this interrupt and the global interrupts are enabled. Setting the Transfer Complete Interrupt Enable (TXCIE) in the Interrupt Control register (SPIn.INTCTRL) enables the Transfer Complete Interrupt.