Freescale Semiconductor, Inc.
*****************************************************************************
*
*
*
*
*
*
*
*
EEPROM Supporting SubRoutines
* These subroutines support the functions called from the Command subs
*
*****************************************************************************
***
J9356_WR_OP
Subroutine to write 3 bit opcode ************************************
ldx #3T ;init counter for LOOP1
*
Write to the serial output pin
J9356_LOOP1
brclr 7,OPCODE,J9356_L1_2 ;if opcode bit7 = 0, goto L1_2
bset
bra
bclr
SER_OUT,PORTA ;ser_out = 1
J9356_L1_3 ;goto L1_3
SER_OUT,PORTA ;ser_out = 0
J9356_L1_2
*
Clock the serial clock pin
J9356_L1_3
bset
bclr
asl
SER_CLK,PORTA ;ser_clk = 1
SER_CLK,PORTA ;ser_clk = 0
OPCODE
;rotate the opcode
decx
bne
clra
sta
;decrease counter loop
;is LOOP1 finished?
J9356_LOOP1
COPR
;kick the wdog
;return
rts
*** Subroutine to write 8 bit address ****************************************
J9356_WR_ADDR ldx #8T ;init counter for LOOP2
*
Write to the serial output pin
J9356_LOOP2
brclr 7,ADDR,J9356_L2_2
bset
bra
;if addr bit7 = 0, goto L2_2
SER_OUT,PORTA ;ser_out = 1
J9356_L2_3 ;goto L2_3
SER_OUT,PORTA ;ser_out = 0
J9356_L2_2
bclr
*
Clock the serial clock pin
J9356_L2_3
bset
bclr
asl
decx
bne
SER_CLK,PORTA ;ser_clk = 1
SER_CLK,PORTA ;ser_clk = 0
ADDR
;rotate the addr
;decrease counter loop
;is LOOP2 finished?
;return
J9356_LOOP2
rts
AN1241/D
For More Information On This Product,
Go to: www.freescale.com
16