132
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
• Bits 7..0 - 2-wire Serial Bit-rate Register
TWBR selects the division factor for the bit-rate generator. The bit-rate generator is a fre-
quency divider which generates the SCL clock frequency in the Master modes according to
the following equation:
•
Bit-rate = SCL frequency
•
f
CK
= CPU Clock frequency
•
TWBR = Contents of the 2-wire Serial Bit Rate Register
Both the receiver and the transmitter can stretch the Low period of the SCL line when waiting
for user response, thereby reducing the average bit rate.
The 2-wire Serial Control Register – TWCR
• Bit 7 - TWINT: 2-wire Serial Interrupt Flag
This bit is set by the hardware when the 2-wire Serial Interface has finished its current job and
expects application software response. If the I-bit in the SREG and TWIE in the TWCR regis-
ter are set (one), the MCU will jump to the interrupt vector at address $0046. While the TWINT
flag is set, the bus SCL clock line Low period is stretched. The TWINT flag must be cleared by
software by writing a logic 1 to it. Note that this flag is not automatically cleared by the hard-
ware when executing the interrupt routine. Also note that clearing this flag starts the operation
of the 2-wire Serial Interface, so all accesses to the 2-wire Serial Address Register – TWAR,
2-wire Serial Status Register – TWSR, and 2-wire Serial Data Register – TWDR must be com-
plete before clearing this flag.
• Bit 6 - TWEA: 2-wire Serial Enable Acknowledge Flag
TWEA flag controls the generation of the acknowledge pulse. If the TWEA bit is set, the ACK
pulse is generated on the 2-wire Serial Bus if the following conditions are met:
•
The device’s own Slave address has been detected
•
A general call has been received, while the TWGCE bit in the TWAR is set
•
A data byte has been received in Master Receiver or Slave Receiver mode
By setting the TWEA bit Low the device can be virtually disconnected from the 2-wire Serial
Bus temporarily. Address recognition can then be resumed by setting the TWEA bit again.
• Bit 5 - TWSTA: 2-wire Serial Bus START Condition Flag
The TWSTA flag is set by the CPU when it desires to become a Master on the 2-wire Serial
Bus. The 2-wire serial hardware checks if the bus is available, and generates a Start condition
on the bus if the bus is free. However, if the bus is not free, the 2-wire Serial Interface waits
until a STOP condition is detected, and then generates a new Start condition to claim the bus
Master status.
Bit
7
6
5
4
3
2
1
0
$36 ($56)
TWINT
TWEA
TWSTA
TWSTO
TWWC
TWEN
-
TWIE
TWCR
Read/Write
R/W
R/W
R/W
R/W
R
R/W
R
R/W
Initial Value
0
0
0
0
0
0
0
0
Bit-rate
f
CK
16 + 2(TWBR)
--------------------------------------
=