Freescale Semiconductor, Inc.
Inter-IC Bus
The following is an example of a software response by a ’master
transmitter’ in the interrupt routine (see Figure 15-4).
ISR
BCLR
IBSR,#$02
;CLEAR THE IBIF FLAG
BRCLR
BRCLR
BRSET
IBCR,#$20,SLAVE
;BRANCH IF IN SLAVE MODE
IBCR,#$10,RECEIVE ;BRANCH IF IN RECEIVE MODE
IBSR,#$01,END
DATABUF,IBDR
;IF NO ACK, END OF TRANSMISSION
;TRANSMIT NEXT BYTE OF DATA
TRANSMIT MOVB
15.7.4 Generation of STOP
A data transfer ends with a STOP signal generated by the ’master’
device. A master transmitter can simply generate a STOP signal after all
the data has been transmitted. The following is an example showing how
a stop condition is generated by a master transmitter.
MASTX
TST
TXCNT
;GET VALUE FROM THE
;TRANSMITING COUNTER
;END IF NO MORE DATA
;END IF NO ACK
BEQ
END
BRSET
MOVB
DEC
IBSR,#$01,END
DATABUF,IBDR
TXCNT
;TRANSMIT NEXT BYTE OF DATA
;DECREASE THE TXCNT
;EXIT
BRA
EMASTX
END
BCLR
RTI
IBCR,#$20
;GENERATE A STOP CONDITION
;RETURN FROM INTERRUPT
EMASTX
If a master receiver wants to terminate a data transfer, it must inform the
slave transmitter by not acknowledging the last byte of data which can
be done by setting the transmit acknowledge bit (TXAK) before reading
the 2nd last byte of data. Before reading the last byte of data, a STOP
signal must be generated first. The following is an example showing how
a STOP signal is generated by a master receiver.
MASR
DEC
RXCNT
;DECREASE THE RXCNT
;LAST BYTE TO BE READ
;CHECK SECOND LAST BYTE
;TO BE READ
BEQ
ENMASR
RXCNT,D1
D1
MOVB
DEC
BNE
NXMAR
;NOT LAST OR SECOND LAST
;SECOND LAST, DISABLE ACK
;TRANSMITTING
LAMAR
BSET
IBCR,#$08
BRA
NXMAR
ENMASR
BCLR
IBCR,#$20
;LAST ONE, GENERATE ‘STOP’ SIGNAL
Technical Data
MC68HC912DG128 — Rev 3.0
Inter-IC Bus
For More Information On This Product,
Go to: www.freescale.com