mcf5307cft90b Freescale Semiconductor, Inc, mcf5307cft90b Datasheet - Page 214

no-image

mcf5307cft90b

Manufacturer Part Number
mcf5307cft90b
Description
Mcf5307 Coldfire Integrated Microprocessor User
Manufacturer
Freescale Semiconductor, Inc
Datasheet
I
TRANSMITMOVE.B DATABUF,-(A7);Stack data byte
8.6.4 Generation of STOP
A data transfer ends when the master signals a STOP, which can occur after all data is sent,
as in the following example.
MASTX
END
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
ENMASR
NXMAR
8.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)
8-12
2
C Programming Examples
BTST.B #5,(A7)+;check the MSTA flag
BEQ.S SLAVE;Branch if slave mode
MOVE.B I2CR,-(A7);Push the address on stack
BTST.B #4,(A7)+;check the mode flag
BEQ.S RECEIVE;Branch if in receive mode
MOVE.B I2SR,-(A7);Push the address on stack,
BTST.B #0,(A7)+;check ACK from receiver
BNE.B END;If no ACK, end of transmission
MOVE.B (A7)+, I2DR;Transmit next byte of data
MOVE.B I2SR, -(A7);If no ACK, branch to end
BTST.B #0,(A7)+
BNE.B END
MOVE.B TXCNT,D0;Get value from the transmitting counter
BEQ.S END;If no more data, branch to end
MOVE.B DATABUF,-(A7);Transmit next byte of data
MOVE.B (A7)+,I2DR
MOVE.B TXCNT,D0;Decrease the TXCNT
SUBQ.L #1,D0
MOVE.B D0,TXCNT
BRA.S EMASTX;Exit
LEA.L I2CR,-(A7);Generate a STOP condition
BCLR.B #5,(A7)+
EMASTX RTE;Return from interrupt
MOVE.B RXCNT,D0;Decrease RXCNT
SUBQ.L #1,D0
MOVE.B D0,RXCNT
BEQ.S ENMASR;Last byte to be read
MOVE.B RXCNT,D1;Check second-to-last byte to be read
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
BCLR.B #5,I2CR;Last one, generate STOP signal
MOVE.B I2DR,RXBUF;Read data and store RTE
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
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MCF5307 User’s Manual

Related parts for mcf5307cft90b