67
ATmega161(L)
1228B–09/01
SPI Status Register – SPSR
• Bit 7
–
SPIF: SPI Interrupt Flag
When a serial transfer is complete, the SPIF bit is set (one) and an interrupt is gener-
ated if SPIE in SPCR is set (one) 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 corresponding interrupt handling vector. Alter-
natively, the SPIF bit is cleared by first reading the SPI status register with SPIF set
(one), then by accessing the SPI Data Register (SPDR).
• Bit 6
–
WCOL: Write Collision Flag
The WCOL bit is set if the SPI Data Register (SPDR) is written during a data transfer.
The WCOL bit (and the SPIF bit) are cleared (zero) by first reading the SPI Status Reg-
ister with WCOL set (one), and then by accessing the SPI Data Register.
• Bits 5..1
–
Res: Reserved Bits
These bits are reserved bits in the ATmega161 and will always read as zero.
• Bit 0
–
SPI2X: Double SPI Speed Bit
When this bit is set (one), the SPI speed (SCK frequency) will be doubled when the SPI
is in master mode (see Table 23). This means that the maximum SCK period will be two
CPU clock periods. When the SPI is configured as slave, the SPI is only guaranteed to
work at f
cl
/4.
The SPI interface on the ATmega161 is also used for program memory and EEPROM
downloading or uploading. See page 123 for serial programming and verification.
SPI Data Register – SPDR
The SPI Data Register is a read/write register used for data transfer between the regis-
ter file and the SPI Shift Register. Writing to the register initiates data transmission.
Reading the register causes the Shift Register Receive buffer to be read.
Bit
7
6
5
4
3
2
1
0
$0E ($2E)
SPIF
WCOL
–
–
–
–
–
SPI2X
SPSR
Read/Write
R
R
R
R
R
R
R
R/W
Initial Value
0
0
0
0
0
0
0
0
Bit
7
6
5
4
3
2
1
0
$0F ($2F)
MSB
LSB
SPDR
Read/Write
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Initial Value
x
x
x
x
x
x
x
x
Undefined