SERIAL COMMUNICATION INTERFACE (SCI)
MOTOROLA
PORT C
6 - 67
;*******************************************************************************************
; SUBROUTINE TO READ SCI AND STORE IN BUFFER USING A LONG INTERRUPT
*
;*******************************************************************************************
RX
JCLR
#7,X:$FFF1,RX_DATA
;Check if this is address or data.
MOVEP
X:SRX,A
;Compare the received address
MOVE
N1,B
;with the slave address.
CMP
A,B
JEQ
END_RX
;If address OK, use interrupts to Rx
;packet
BSET
#6,X:$FFF0
;if not, go back to sleep
JMP
END_RX
;and return to previous program.
RX_DATA
MOVEP
X:SRX,X:(R3)+
;Put data in buffer,
MOVE
N2,X:RX_MTY
;and clear the Rx buffer empty flag
END_RX
RTI
;Return to previous program
;*******************************************************************************************
;
SUBROUTINE TO WRITE BUFFER TO SCI USING A LONG INTERRUPT
*
;*******************************************************************************************
TX
MOVEP
X:(R0)+,X:STX
;Transmit a byte and increment the
;pointer
MOVE
R0,A
;Check to see if the TX buffer is
;empty
MOVE
R1,B
CMP
A,B
JNE
END_TX
;If not, return to main
MOVE
#$000001,X0
;If it is, set the TX buffer empty flag
MOVE
X0,X:TX_MTY
BCLR
#12,X:SCR
;disable transmit interrupts, and
END_TX
RTI
;return to main
;*******************************************************************************************
;
SUBROUTINE TO WAKE UP THE ADDRESSED SLAVE
*
;*******************************************************************************************
WAKE_UP
MOVEP
N1,X:STXA
;Transmit slave address using STXA
;not STX
BSET
#12,X:SCR
;Enable transmit interrupts to send
;packet
AWAKE
RTI
END
;End of example.
Figure 6-34 Multidrop Transmit/Receive Example (Sheet 4 of 4)
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..