ATMEGA48V_11 ATMEL [ATMEL Corporation], ATMEGA48V_11 Datasheet - Page 238

no-image

ATMEGA48V_11

Manufacturer Part Number
ATMEGA48V_11
Description
8-bit Atmel Microcontroller with 4/8/16K Bytes In-System Programmable Flash
Manufacturer
ATMEL [ATMEL Corporation]
Datasheet
22.9.3
22.9.4
2545T–AVR–05/11
TWSR – TWI status register
TWDR – TWI data register
• 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.
• 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 22-7.
To calculate bit rates, see
in the equation.
In Transmit mode, TWDR contains the next byte to be transmitted. In Receive mode, the TWDR
contains the last byte received. It is writable while the TWI is not in the process of shifting a byte.
This occurs when the TWI Interrupt Flag (TWINT) is set by hardware. Note that the Data Regis-
ter cannot be initialized by the user before the first interrupt occurs. The data in TWDR remains
stable as long as TWINT is set. While data is shifted out, data on the bus is simultaneously
shifted in. TWDR always contains the last byte present on the bus, except after a wake up from
a sleep mode by the TWI interrupt. In this case, the contents of TWDR is undefined. In the case
Bit
(0xB9)
Read/write
Initial value
Bit
(0xBB)
Read/write
Initial value
TWPS1
0
0
1
1
TWI bit rate prescaler.
TWS7
TWD7
R/W
R
7
1
7
1
TWD6
TWS6
R/W
TWPS0
0
1
0
1
R
“Bit rate generator unit” on page
6
1
6
1
TWD5
TWS5
R/W
R
5
1
5
1
TWD4
TWS4
R/W
R
4
1
4
1
Prescaler value
1
4
16
64
TWD3
TWS3
R/W
R
3
1
3
1
216. The value of TWPS1..0 is used
TWD2
R/W
ATmega48/88/168
R
2
1
2
0
TWPS1
TWD1
R/W
R/W
1
1
1
0
TWPS0
TWD0
R/W
R/W
0
1
0
0
TWDR
TWSR
238

Related parts for ATMEGA48V_11