1. Update the Control Register 1 (SPIx_C1) to enable the SPI and to control interruptenables. This register also sets the SPI as master or slave, determines clock phase andpolarity, and configures the main SPI options.2. Update the Control Register 2 (SPIx_C2) to enable additional SPI functions such asthe SPI match interrupt feature, the master mode-fault function, and bidirectionalmode output as well as to control 8- or 16-bit mode selection and other optionalfeatures.3. Update the Baud Rate Register (SPIx_BR) to set the prescaler and bit rate divisor foran SPI master.4. Update the Hardware Match Register (SPIx_MH:SPIx_ML) with the value to becompared to the receive data register for triggering an interrupt if hardware matchinterrupts are enabled.5. In the master, read SPIx_S while S[SPTEF] = 1, and then write to the transmit dataregister (SPIx_DH:SPIx_DL) to begin transfer.35.6.2 Pseudo-Code ExampleIn this example, the SPI module is set up for master mode with only hardware matchinterrupts enabled. The SPI runs in 16-bit mode at a maximum baud rate of SPI moduleclock divided by 2. Clock phase and polarity are set for an active-high SPI clock wherethe first edge on SPSCK occurs at the start of the first cycle of a data transfer.SPIx_C1=0x54(%01010100)Bit 7 SPIE = 0 Disables receive and mode fault interruptsBit 6 SPE = 1 Enables the SPI systemBit 5 SPTIE = 0 Disables SPI transmit interruptsBit 4 MSTR = 1 Sets the SPI module as a master SPI deviceBit 3 CPOL = 0 Configures SPI clock as active-highBit 2 CPHA = 1 First edge on SPSCK at start of first data transfer cycleBit 1 SSOE = 0 Determines SS pin function when mode fault enabledBit 0 LSBFE = 0 SPI serial data transfers start with most significant bitSPIx_C2 = 0xC0(%11000000)Bit 7 SPMIE = 1 SPI hardware match interrupt enabledBit 6 SPIMODE = 1 Configures SPI for 16-bit modeBit 5 TXDMAE = 0 DMA request disabledBit 4 MODFEN = 0 Disables mode fault functionTable continues on the next page...Initialization/application informationKL27 Sub-Family Reference Manual , Rev. 5, 01/2016606 Freescale Semiconductor, Inc.