26.3.1 Initialization
Initialize the SPI to a basic functional state by following these steps:
- Configure the SS pin in the port peripheral.
- Select the SPI host/client operation by writing the Host/Client Select (MASTER) bit in the Control A (SPIn.CTRLA) register.
- In Host mode, select the clock speed by writing the Prescaler (PRESC) bits and the Clock Double (CLK2X) bit in SPIn.CTRLA.
- Optional: Select the Data Transfer mode by writing to the MODE bits in the Control B (SPIn.CTRLB) register.
- Optional: Write the Data Order (DORD) bit in SPIn.CTRLA.
- Optional: Set up the Buffer mode by writing the BUFEN and BUFWR bits in the Control B (SPIn.CTRLB) register.
- Optional: To disable the multi-host
support in Host mode, write ‘
1
’ to the Client Select Disable (SSD) bit in SPIn.CTRLB. - Enable the SPI by writing a
‘
1
’ to the ENABLE bit in SPIn.CTRLA.