
174
7593L–AVR–09/12
AT90USB64/128
Bit 3 – CPOL: Clock Polarity
When this bit is written to one, SCK is high when idle. When CPOL is written to zero, SCK is low
Bit 2 – CPHA: Clock Phase
The settings of the Clock Phase bit (CPHA) determine if data is sampled on the leading (first) or
Bits 1, 0 – SPR1, SPR0: SPI Clock Rate Select 1 and 0
These two bits control the SCK rate of the device configured as a Master. SPR1 and SPR0 have
no effect on the Slave. The relationship between SCK and the Oscillator Clock frequency f
osc is
18.1.4
SPSR – SPI Status Register
Bit 7 – SPIF: SPI Interrupt Flag
When a serial transfer is complete, the SPIF Flag is set. An interrupt is generated if SPIE in
SPCR is set and global interrupts are enabled. If SS is an input and is driven low when the SPI is
in Master mode, this will also set the SPIF Flag. SPIF is cleared by hardware when executing the
Table 18-2.
CPOL functionality.
CPOL
Leading edge
Trailing edge
0
Rising
Falling
1
Falling
Rising
Table 18-3.
CPHA functionality.
CPHA
Leading edge
Trailing edge
0
Sample
Setup
1
Setup
Sample
Table 18-4.
Relationship between SCK and the oscillator frequency.
SPI2X
SPR1
SPR0
SCK frequency
00
0
f
osc/4
00
1
f
osc/16
01
0
f
osc/64
01
1
f
osc/128
10
0
f
osc/2
10
1
f
osc/8
11
0
f
osc/32
11
1
f
osc/64
Bit
7
65
43
21
0
SPIF
WCOL
–
SPI2X
SPSR
Read/write
RR
RR/W
Initial value
00