![Freescale Semiconductor QE128 Скачать руководство пользователя страница 96](http://html1.mh-extra.com/html/freescale-semiconductor/qe128/qe128_quick-reference-user-manual_2330661096.webp)
Using the Serial Peripheral Interface (SPI) for the QE Microcontrollers
QE128 Quick Reference User Guide, Rev. 1.0
11-4
Freescale Semiconductor
This is the initialization code for the SPI module used for the QE MCU. This application configures the
SPI module to work in slave mode.
void SPI_Init (void) {
SPI2BR = 0x75; // Select the highest baud rate prescaler divisor and the
// highest baud rate divisor
SPI2C1 = 0xC4; // SPI Interrupt enable, system enable and slave mode selected
SPI2C2 = 0x00; // Different pins for data input and data output
}
NOTE
This is the SPI interrupt service routine. This routine is used when a byte is
sent by the master to the slave.
void interrupt VectorNumber_Vspi2 SPI_ISR(void) {
UINT8 temp, buffer;
while (PTDD_PTDD0);
temp = SPI2S; // Clear register flag
buffer = SPI2D;// Read data register to clear receive flag
PTED = buffer;
}
For detailed information about the code, refer to the SPI_Slave project from the QRUG examples.