
I2C Interface
MCF5271 Reference Manual, Rev. 2
25-16
Freescale Semiconductor
EXTB.L D1
SUBI.L #1,D1;
BNE.S NXMAR
;Not last one or second last
LAMAR BSET.B #3,I2CR
;Disable ACK
BRA NXMAR
ENMASR BCLR.B #5,I2CR
;Last one, generate STOP signal
NXMAR
MOVE.B I2DR,RXBUF
;Read data and store RTE
25.6.5 Generation of Repeated START
After the data transfer, if the master still wants the bus, it can signal another START followed by
another slave address without signalling a STOP, as in the following example.
RESTART MOVE.B I2CR,-(A7)
;Repeat START (RESTART)
BSET.B #2, (A7)
MOVE.B (A7)+, I2CR
MOVE.B CALLING,-(A7)
;Transmit the calling address, D0=R/W-
MOVE.B CALLING,-(A7)
MOVE.B (A7)+, I2DR
25.6.6 Slave Mode
In the slave interrupt service routine, software should poll the I2SR[IAAS] bit to determine if the
controller has received its slave address. If IAAS is set, software should set the transmit/receive
mode select bit (I2CR[MTX]) according to the I2SR[SRW]. Writing to the I2CR clears the 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 will 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 then releases I2C_SCL so that the
master can generate a STOP signal.
25.6.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 is still generated 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] = 1 and
I2CR[MSTA] = 0.