5 generation of repeated start, 6 slave mode, 7 arbitration lost – Motorola ColdFire MCF5281 User Manual

Page 468

Advertising
background image

I

2

C Interface

24-14

Freescale Semiconductor

For a master receiver to terminate a data transfer, it must inform the slave transmitter by not
acknowledging the last data byte. This is done by setting I2CR[TXAK] before reading the next-to-last
byte. Before the last byte is read, a STOP signal must be generated, as in the following example.

1. Decrement RXCNT.

2. If last byte (RXCNT = 0) go to step #4.

3. If next to last byte (RXCNT = 1), set I2CR[TXAK] to disable ACK and go to step #5.

4. This is last byte, so clear I2CR[MSTA] to generate a STOP signal.

5. Read data from I2DR.

6. If there is more data to be read (RXCNT

0), go to step #1 if desired.

24.4.5

Generation of Repeated START

If the master wants the bus after the data transfer, it can signal another START followed by another slave
address without signaling a STOP, as in the following example.

1. Generate a repeated START by setting I2CR[RSTA].

2. Transmit the calling address via I2DR.

24.4.6

Slave Mode

In the slave interrupt service routine, software must poll the I2SR[IAAS] bit to determine if the controller
has received its slave address. If IAAS is set, software must set the transmit/receive mode select bit
(I2CR[MTX]) according to the I2SR[SRW]. Writing to I2CR clears IAAS automatically. The only time
IAAS is read as set is from the interrupt at the end of the address cycle where an address match occurred;
interrupts resulting from subsequent data transfers have IAAS cleared. A data transfer can now be initiated
by writing information to I2DR for slave transmits, or read from I2DR in slave-receive mode. A dummy
read of I2DR in slave/receive mode releases I2C_SCL, allowing the master to send data.

In the slave transmitter routine, I2SR[RXAK] must be tested before sending the next byte of data. Setting
RXAK means an end-of-data signal from the master receiver, after which software must switch it from
transmitter to receiver mode. Reading I2DR releases I2C_SCL so the master can generate a STOP signal.

24.4.7

Arbitration Lost

If several devices try to engage the bus at the same time, one becomes master. Hardware immediately
switches devices that lose arbitration to slave receive mode. Data output to I2C_SDA stops, but I2C_SCL
continues generating until the end of the byte during which arbitration is lost. An interrupt occurs at the
falling edge of the ninth clock of this transfer with I2SR[IAL] set and I2CR[MSTA] cleared.

If a non-master device tries to transmit or execute a START, hardware inhibits the transmission, clears
MSTA without signaling a STOP, generates an interrupt to the CPU, and sets IAL to indicate a failed
attempt to engage the bus. When considering these cases, slave service routine should first test IAL and
software should clear it if it is set.

MCF5282 and MCF5216 ColdFire Microcontroller User’s Manual, Rev. 3

Advertising
This manual is related to the following products: