English
Language : 

AT43USB320A_04 Datasheet, PDF (53/115 Pages) ATMEL Corporation – Full-speed USB Microcontroller with an Embedded Hub
AT43USB320A
The interconnection between master and slave CPUs with SPI is shown in Figure 16. The
PB7(SCK) pin is the clock output in the master mode and is the clock input in the slave mode.
Writing to the SPI data register of the master CPU starts the SPI clock generator, and the data
written shifts out of the PB5(MOSI) pin and into the PB5(MOSI) pin of the slave CPU. After
shifting one byte, the SPI clock generator stops, setting the end of transmission flag (SPIF). If
the SPI interrupt enable bit (SPIE) in the SPCR register is set, an interrupt is requested. The
Slave Select input, PB4(SS), is set low to select an individual slave SPI device. The two shift
registers in the Master and the Slave can be considered as one distributed 16-bit circular shift
register. This is shown in Figure 16. When data is shifted from the master to the slave, data is
also shifted in the opposite direction, simultaneously. This means that during one shift cycle,
data in the master and the slave are interchanged.
Figure 16. SPI Master/Slave Interconnection
MSB
MASTER
LSB
8-bit Shift Register
MISO MISO
MSB
SLAVE
LSB
8-bit Shift Register
MOSI MOSI
SPI
Clock Generator
SCK
SS
VCC
SCK
SS
The system is single buffered in the transmit direction and double buffered in the receive direc-
tion. This means that bytes to be transmitted cannot be written to the SPI Data Register before
the entire shift cycle is completed. When receiving data, however, a received byte must be
read from the SPI Data Register before the next byte has been completely shifted in. Other-
wise, the first byte is lost.
When the SPI is enabled, the data direction of the MOSI, MISO, SCK and SS pins is overrid-
den according to the following table:
Table 20. SPI Pin Overrides
Pin
Direction, Master SPI
Direction, Slave SPI
MOSI
User Defined
Input
MISO
Input
User Defined
SCK
User Defined
Input
SSN
User Defined
Input
Note: See “Port B” on page 64. for a detailed description of how to define the direction of the user
defined SPI pins.
53
1443E–USB–4/04