English
Language : 

ATMEGA164P_1 Datasheet, PDF (237/377 Pages) ATMEL Corporation – 8-bit Microcontroller with 16/32/64K Bytes In-System Programmable Flash
ATmega164P/324P/644P
• Bit 3 – TWWC: TWI Write Collision Flag
The TWWC bit is set when attempting to write to the TWI Data Register – TWDR when TWINT is
low. This flag is cleared by writing the TWDR Register when TWINT is high.
• Bit 2 – TWEN: TWI Enable Bit
The TWEN bit enables TWI operation and activates the TWI interface. When TWEN is written to
one, the TWI takes control over the I/O pins connected to the SCL and SDA pins, enabling the
slew-rate limiters and spike filters. If this bit is written to zero, the TWI is switched off and all TWI
transmissions are terminated, regardless of any ongoing operation.
• Bit 1 – Res: Reserved Bit
This bit is a reserved bit and will always read as zero.
19.9.3
• Bit 0 – TWIE: TWI Interrupt Enable
When this bit is written to one, and the I-bit in SREG is set, the TWI interrupt request will be acti-
vated for as long as the TWINT Flag is high.
TWSR – TWI Status Register
Bit
(0xB9)
Read/Write
Initial Value
7
TWS7
R
1
6
TWS6
R
1
5
TWS5
R
1
4
TWS4
R
1
3
TWS3
R
1
2
1
0
–
TWPS1 TWPS0
TWSR
R
R/W
R/W
0
0
0
• Bits 7:3 – TWS: TWI Status
These 5 bits reflect the status of the TWI logic and the 2-wire Serial Bus. The different status
codes are described later in this section. Note that the value read from TWSR contains both the
5-bit status value and the 2-bit prescaler value. The application designer should mask the pres-
caler bits to zero when checking the Status bits. This makes status checking independent of
prescaler setting. This approach is used in this datasheet, unless otherwise noted.
• Bit 2 – Res: Reserved Bit
This bit is reserved and will always read as zero.
• Bits 1:0 – TWPS: TWI Prescaler Bits
These bits can be read and written, and control the bit rate prescaler.
Table 19-7.
TWPS1
0
0
1
1
TWI Bit Rate Prescaler
TWPS0
0
1
0
1
Prescaler Value
1
4
16
64
To calculate bit rates, see “Bit Rate Generator Unit” on page 216. The value of TWPS1..0 is
used in the equation.
7674F–AVR–09/09
237