3.10.8.3.1 SPCR – SPI Configuration Register

Name: SPCR
Offset: 0x02C
Reset: 0x00

Bit 76543210 
 SPIESPEDORD MSTRCPHASPR[1:0] 
Access R/WR/WR/WR/WR/WR/WR/W 
Reset 0000000 

Bit 7 – SPIE SPI Interrupt Enable

This bit causes the SPI interrupt to be executed if the SPIF bit in the SPSR register is set and if the global interrupt enable bit in SREG is set.

Bit 6 – SPE SPI Enable

When the SPE bit is written to ‘1’, the SPI is enabled. This bit must be set to enable any SPI operations.

Bit 5 – DORD Data Order

If the DORD bit is written to ‘1’, the LSB of the data word is transmitted first. If the DORD bit is written to ‘0’, the MSB of the data word is transmitted first.

Bit 3 – MSTR Host/Client Select

This bit selects SPI Host mode when written to ‘1’ and client SPI mode when written to logic ‘0’. If NSS is configured as an input and is driven low while MSTR is set, MSTR is cleared and SPIF in SPSR is set. The user then has to set MSTR to re-enable SPI Host mode.

Bit 3 – CPOL Clock Polarity

If this bit is written to ‘1’, SCK is high when idle. If CPOL is written to ‘0’, SCK is low when idle. Refer to Figure 3-90 and Figure 3-91 for an example. The CPOL functionality is summarized in the following table.
Table 3-105. CPOL Functionality
CPOLLeading EdgeTrailing Edge
0RisingFalling
1FallingRising

Bit 2 – CPHA Clock Phase

The setting of the clock phase (CPHA) determines if data is sampled on the leading (first) or trailing (last) edge of SCK. Refer to Figure 3-90 and Figure 3-91 for an example. The CPHA functionality is summarized in the following table.
Table 3-106. CPHA Functionality
CPHALeading EdgeTrailing Edge
0SampleSetup
1SetupSample

Bits 1:0 – SPR[1:0] SPI Clock Rate Select

These two bits control the SCK rate of the device configured as a host. SPR[1:0] has no effect on the client. The relationship between SCK and the CLKI/O is shown in the following table.
Table 3-107. Relationship Between SCK and Oscillator Frequency
SPSR.SPI2XSPR1SPR0SCK Frequency
000CLKI/O/4
001CLKI/O/16
010CLKI/O/64
011CLKI/O/128
100CLKI/O/2
101CLKI/O/8
110CLKI/O/32
111CLKI/O/64