English
Language : 

MC68HC05BD3 Datasheet, PDF (58/112 Pages) Motorola, Inc – HCMOS microcontroller
MIF bit in the interrupt routine first. The MCF bit can be cleared by reading the M-Bus Data I/O
Register (MDR) in receive mode or writing to the MDR in transmit mode. Software may serve the
M-Bus I/O in the main program by monitoring the MIF bit if the interrupt is disabled. The following
is an example of a software response by a master in transmit mode in the interrupt routine (see
Figure 7-4).
ISR
TRANSMIT
BCLR
BRCLR
BRCLR
BRSET
LDA
STA
1,MSR
; CLEAR THE MIF FLAG
5,MCR,SLAVE ; CHECK THE MSTA FLAG,
; BRANCH IF SLAVE MODE
4,MCR,RECEIVE ; CHECK THE MODE FLAG,
; BRANCH IF IN RECEIVE MODE
0,MSR,END ; CHECK ACK FROM RECEIVER
; IF NO ACK, END OF
; TRANSMISSION
DATABUF
; GET THE NEXT BYTE OF DATA
MDR
; TRANSMIT THE DATA
7.4.4 Generation of the STOP Signal
7
A data transfer ends with a STOP signal generated by the master device. A master in transmit
mode can simply generate a STOP signal after all the data have been transmitted. The following
is an example showing how a STOP condition is generated by a master in transmit mode.
MASTX BRSET 0,MSR,END
LDA TXCNT
BEQ END
LDA
STA
DEC
BRA
END BCLR
EMASTX RTI
DATABUF
MDR
TXCNT
EMASTX
5,MCR
; IF NO ACK, BRANCH TO END
; GET VALUE FROM THE
; TRANSMITTING COUNTER
; IF NO MORE DATA, BRANCH TO
; END
; GET NEXT BYTE OF DATA
; TRANSMIT THE DATA
; DECREASE THE TXCNT
; EXIT
; GENERATE A STOP CONDITION
; RETURN FROM INTERRUPT
If a master receiver wants to terminate a data transfer, it must inform the slave transmitter by not
acknowledging the last byte of data. This can be achieved 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 in receive mode.
MASR
DEC
BEQ
LDA
DECA
BNE
RXCNT
ENMASR
RXCNT
NXMAR
; LAST BYTE TO BE READ
; CHECK LAST 2ND BYTE TO BE READ
; NOT LAST ONE OR LAST SECOND
MOTOROLA
7-12
M-BUS SERIAL INTERFACE
TPG
MC68HC05BD3