Generation Of Repeated Start; Slave Mode - Motorola ColdFire MCF5281 User Manual

Motorola microcontroller user's manual
Table of Contents

Advertisement

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.
MASR
MOVE.B RXCNT,D0
SUBQ.L #1,D0
MOVE.B D0,RXCNT
BEQ.S ENMASR
MOVE.B RXCNT,D1
EXTB.L D1
SUBI.L #1,D1;
BNE.S NXMAR
LAMAR BSET.B #3,I2CR
BRA NXMAR
ENMASR
BCLR.B #5,I2CR
NXMAR
MOVE.B I2DR,RXBUF

24.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)
BSET.B #2, (A7)
MOVE.B (A7)+, I2CR
MOVE.B CALLING,-(A7)
MOVE.B CALLING,-(A7)
MOVE.B (A7)+, I2DR

24.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 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 SCL
so that the master can generate a STOP signal.
MOTOROLA
;Decrease RXCNT
;Last byte to be read
;Check second-to-last byte to be read
;Not last one or second last
;Disable ACK
;Last one, generate STOP signal
;Read data and store RTE
;Repeat START (RESTART)
;Transmit the calling address, D0=R/W-
2
Chapter 24. I
C Interface
2
I
C Programming Examples
24-13

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfire mcf5282

Table of Contents