English
Language : 

AN1445 Datasheet, PDF (1/7 Pages) STMicroelectronics – USING THE ST7 SPI TO EMULATE A 16-BIT SLAVE
AN1445
APPLICATION NOTE
USING THE ST7 SPI TO EMULATE A 16-BIT SLAVE
By Microcontroller Division Applications
INTRODUCTION
This application note describes how to emulate a 16-bit slave SPI using an ST7 microcon-
troller with an on-chip 8-bit SPI.
Figure 1. 16-bit SPI frame
bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 12 bit 13 bit 14bit 15
1 PRINCIPLE
The ST7 SPI cell has a double buffer for receiving data using two 8-bit registers: a read reg-
ister and a shift register (see Figure 2.). The application software accesses the read register to
retrieve the received data. The 8-bit shift register is managed by hardware to receive the 8 bits
of each byte. As each bit is received, it is shifted into the shift register. During byte reception,
the read register is not changed. It contains the previously received byte which can still be
read by software. At the end of byte reception, the 8-bit shift register is copied into the read
register.
This double buffering makes it possible to receive 16-bit words. At the end of reception of the
first byte, the shift register is copied into the read register, the SPIF flag is set and an interrupt
can be generated. The next in-coming byte will be received in the shift register while the first
byte is available in the read register. In order not to lose any bits, the software must be fast
enough to read the first byte before the end of the reception of the second one.
Note: The SPISR (SPI Status Register) is also called SPICSR (SPI Control/Status Register)
depending on which ST7 microcontroller device you use. In this application note, we’ll use the
name SPISR for the status register.
AN1445/1101
1/7
1