19.4.1.2 8-Bit, 16-Bit and 32-Bit Operation

The SPI module allows three types of data widths when transmitting and receiving data over an SPI bus. The selection of data width determines the minimum length of SPI data. For example, when the selected data width is 32, all transmission and receptions are performed in 32-bit values. All reads and writes from the CPU are also performed in 32-bit values. Accordingly, the application software should select the appropriate data width to maximize its data throughput.

Two control bits, MODE32 and MODE16 (SPIxCON1[11:10]), which are referred to as MODE[32,16], define the mode of operation. To change the mode of operation on-the-fly, the SPI module must be Idle (i.e., not performing any transactions). If the SPI module is switched off (SPIxCON1[15] = 0), the new mode will be available when the module is again switched on.

Additionally, the following items should be noted in this context:

  • The MODE[32,16] bits should not be changed when a transaction is in progress
  • The first bit to be shifted out from SPIxTXSR varies with the selected mode of operation:
    • 8-bit mode, bit 7
    • 16-bit mode, bit 15
    • 32-bit mode, bit 31
  • In each mode, data is shifted into bit 0 of the SPIxRXSR
  • The number of clock pulses at the SCKx pin are also dependent on the selected mode of operation:
    • 8-bit mode, 8 clocks
    • 16-bit mode, 16 clocks
    • 32-bit mode, 32 clocks