
560
SAM G51 [DATASHEET]
11209C–ATARM–20-Dec-13
27.7.3 Master Mode
27.7.3.1
Definition
The master is the device that starts a transfer, generates a clock and stops it. This operating mode is not available if high-
speed mode is selected.
27.7.3.2
Application Block Diagram
Figure 27-6.
Master Mode Typical Application Block Diagram
27.7.3.3
Programming Master Mode
The following registers must be programmed before entering master mode:
1.
DADR (+ IADRSZ + IADR if a 10-bit device is addressed): The device address is used to access slave devices in
read or write mode.
2.
CKDIV + CHDIV + CLDIV: Clock waveform.
3.
SVDIS: Disables the slave mode.
4.
MSEN: Enables the master mode.
Note:
If the TWI is already in Master mode, the device address (DADR) can be configured without disabling the Master
mode
27.7.3.4
Master Transmitter Mode
This operating mode is not available if high-speed mode is selected.
After the master initiates a START condition when writing into the Transmit Holding register TWIHS_THR, it sends a 7-bit
slave address, configured in the Master Mode register (DADR in TWIHS_MMR), to notify the slave device. The bit
following the slave address indicates the transfer direction, 0 in this case (MREAD = 0 in TWIHS_MMR).
The TWI transfers require the slave to acknowledge each received byte. During the acknowledge clock pulse (ninth
pulse), the master releases the data line (HIGH), enabling the slave to pull it down in order to generate the acknowledge.
The master polls the data line during this clock pulse and sets the Not Acknowledge bit (NACK) in the status register if
the slave does not acknowledge the byte. As with the other status bits, an interrupt can be generated if enabled in the
interrupt enable register (TWIHS_IER). If the slave acknowledges the byte, the data written in the TWIHS_THR is then
shifted in the internal shifter and transferred. When an acknowledge is detected, the TXRDY bit is set until a new write in
the TWIHS_THR.
TXRDY is used as transmit ready for the PDC transmit channel.
While no new data is written in the TWIHS_THR, the serial clock line is tied low. When new data is written in the
TWIHS_THR, the SCL is released and the data is sent. To generate a STOP event, the STOP command must be
performed by writing in the STOP field of TWIHS_CR.
Host with
TWI
Interface
TWD
TWCK
Atmel TWI
Serial EEPROM
IC RTC
IC LCD
Controller
Slave 1
Slave 2
Slave 3
VDD
IC Temp.
Sensor
Slave 4
Rp: Pull up value as given by the IC Standard
Rp