Setting the EN bit enables the SPI peripheral. However, to reset or reconfigure the SPI mode the EN bit must be cleared.
Setting the EN bit enables the SPI inputs and outputs: SDI, SDO, SCK_out, SCK_in, SS_out, and SS_in. The pins for all of these inputs and outputs are selected by the PPS controls, and thus must have their functions mapped properly to the device pins to function. Refer to the “PPS - Peripheral Pin Select Module” chapter for more detail.
SS_out and SCK_out must have the pins to which they are assigned set as
outputs (TRIS bits must be ‘0’) in order to properly output. Clearing
the TRIS bit of the SDO pin will cause the SPI module to always control that pin, but is
not necessary for SDO functionality. (see Input and Output Polarity Control)
Clearing the EN bit aborts any transmissions in progress, disables the setting of interrupt flags by hardware, and resets the FIFO occupancy. (see Transmit and Receive FIFOs)