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