
128
ATmega8515(L)
2512A–AVR–04/02
• Bit 4 – MSTR: Master/Slave Select
Thisbit selectsMasterSPI mode when writtentoone, andSlave SPI mode when written
logiczero. If SS
isconfigured as an input and isdriven lowwhile MSTR isset,MSTR will
be cleared, andSPIF in SPSR will become set. Theuserwill then have to set MSTR to
re-enable SPIMaster mode.
• Bit3–CPOL:ClockPolarity
When thisbit iswritten to one,SCKishighwhen idle. When CPOL iswritten to zero,
SCK islowwhen idle. Refer to Figure 61andFigure 62 for an example. The CPOL func-
tionality issummarizedbelow:
• Bit 2 – CPHA: Clock Phase
The settings of the Clock Phase bit (CPHA)determine ifdata issampled on the leading
(first) or trailing (last) edge ofSCK.Refer to Figure 61andFigure 62 for an example.
The CPOL functionality issummarizedbelow:
• Bits 1, 0 – SPR1, SPR0: SPI Clock Rate Select 1 and 0
Thesetwo bitscontrol the SCK rate of the device configured as amaster. SPR1 and
SPR0 havenoeffectonthe Slave. The relationshipbetween SCK and the Oscillator
Clock frequency f
osc
isshowninthe following table:
Table 56. CPOL Functionality
CPOL Leading Edge Trailing Edge
0Rising Falling
1 Falling Rising
Table 57. CPHA Functionality
CPHA Leading Edge Trailing Edge
0 Sample Setup
1 SetupSample
Table 58. RelationshipBetween SCK and the OscillatorFrequency
SPI2X SPR1 SPR0 SCK Frequency
000
f
osc
/4
001
f
osc
/16
010
f
osc
/64
011
f
osc
/128
100
f
osc
/2
101
f
osc
/8
110
f
osc
/32
111
f
osc
/64
Komentáře k této Příručce