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 SPI master/slave operation by writing the Master/Slave Select bit (MASTER) in the Control A register (SPIn.CTRLA).
- In Master mode, select the clock speed by writing the Prescaler bits (PRESC) and the Clock Double bit (CLK2X) in SPIn.CTRLA.
- Optional: Select the Data Transfer mode by writing to the MODE bits in the Control B register (SPIn.CTRLB).
- Optional: Write the Data Order bit (DORD) in SPIn.CTRLA.
- Optional: Setup Buffer mode by writing BUFEN and BUFWR bits in the Control B register (SPIn.CTRLB).
- Optional: To disable the multi-master
support in Master mode, write ‘
1
’ to the Slave Select Disable bit (SSD) in SPIn.CTRLB. - Enable the SPI by writing a
‘
1
’ to the ENABLE bit in SPIn.CTRLA.