Freescale Semiconductor, Inc.
*** Subroutine to write 16 bit data ******************************************
J9356_WR_DATA ldx
#16T
;init counter for LOOP4
*
Write the serial output pin with data
J9356_LOOP4
brclr 7,DATA_H,J9356_L4_2 ;if addr bit7 = 0, goto L4_2
bset
bra
bclr
SER_OUT,PORTA ;ser_out = 1
J9356_L4_3 ;goto L4_3
SER_OUT,PORTA ;ser_out = 0
J9356_L4_2
*
Clock the serial clock pin
J9356_L4_3
bset
bclr
asl
rol
decx
bne
SER_CLK,PORTA ;ser_clk = 1
SER_CLK,PORTA ;ser_clk = 0
DATA_L
DATA_H
;rotate the DATA_L
;rotate the DATA_H
;decrease counter loop
;is LOOP4 finished?
;return
J9356_LOOP4
rts
***
Subroutine to read 16 bit data ***************************************
#16T ;init counter for LOOP3
J9356_RD_DATA ldx
*
Read the serial input pin
J9356_LOOP3
J9356_L3
brclr SER_IN,PORTA,J9356_L3 ;carry bit = serial in
rol
rol
DATA_L
DATA_H
;rotate left result
*
Clock the serial clock pin
bset
bclr
decx
bne
SER_CLK,PORTA ;ser_clk = 1
SER_CLK,PORTA ;ser_clk = 0
;decrease counter loop
;is LOOP3 finished?
;return
J9356_LOOP3
rts
*
Wait until write cycle is over
J9356_WAIT
J9356_W2
bset
clra
sta
CS,PORTA
;CS line is high
;kick the wdog
COPR
brclr SER_IN,PORTA,J9356_W2
bclr
rts
CS,PORTA
;CS line is low
;return
AN1241/D
For More Information On This Product,
Go to: www.freescale.com
17