
591
SAM G51 [DATASHEET]
11209C–ATARM–20-Dec-13
— Data Receive with the PDC in Slave Mode
The following procedure shows an example to transmit data with PDC where the number of characters to receive is
known.
1.
Initialize the receive PDC (memory pointers, transfer size).
2.
Set the PDC RXTEN bit.
3.
Wait for the PDC ENDRX flag either by using polling method or ENDRX interrupt.
4.
Disable the PDC by setting the PDC RXTDIS bit.
5.
(Optional) Wait for the TXCOMP flag in TWIHS_SR before disabling the peripheral clock if required.
SMBus Mode
SMBus mode is enabled when SMEN bit is written to one in TWIHS_CR. SMBus mode operation is similar to IC
operation with the following exceptions:
1.
Only 7-bit addressing can be used.
2.
The SMBus standard describes a set of timeout values to ensure progress and throughput on the bus. These time-
out values must be programmed into the TWIHS_SMBTR.
3.
Transmissions can optionally include a CRC byte, called Packet Error Check (PEC).
4.
A dedicated bus line, SMBALERT, allows a slave to get a master attention.
5.
A set of addresses have been reserved for protocol handling, such as alert response address (ARA) and host
header (HH) address. Address matching on these addresses can be enabled by configuring TWIHS_CR
appropriately.
— Packet Error Checking
Each SMBus transfer can optionally end with a CRC byte, called the PEC byte. Writing the PECEN bit in TWIHS_CR to
one will send/check the PEC field in the current transfer. The PEC generator is always updated on every bit transmitted
or received, so that PEC handling on following linked transfers will be correct.
In slave receiver mode, the master calculates a PEC value and transmits it to the slave after all data bytes have been
transmitted. Upon reception of this PEC byte, the slave will compare it to the PEC value it has computed itself. If the
values match, the data was received correctly, and the slave will return an ACK to the master. If the PEC values differ,
data was corrupted, and the slave will return a NACK value. The PECERR bit in TWIHS_SR is set automatically if a PEC
error occurred.
In slave transmitter mode, the slave calculates a PEC value and transmits it to the master after all data bytes have been
transmitted. Upon reception of this PEC byte, the master will compare it to the PEC value it has computed itself. If the
values match, the data was received correctly. If the PEC values differ, data was corrupted, and the master must take
appropriate action.
— Timeouts
The TWI SMBus Timing Register (TWIHS_SMBTR) configures the SMBus timeout values. If a timeout occurs, the slave
will leave the bus. The TOUT bit is also set in TWIHS_SR.