MICROCHIP 93LC56X-I/SN

Using the 93LC56 and 93LC66
AN560
Using the 93LC56 and 93LC66
INTRODUCTION
3-Wire Byte Write Program
The Microchip Technology Inc. 93LC56/66 are lowpower 3-wire non-volatile memories and are suitable for
many embedded system code and data storage applications. These devices are easily interfaced to most microcontrollers in today's market place, but Microchip’s 8-bit
RISC series PIC16CXX offers the best code density of
any microcontroller on the market today. Using the
PIC16C54, the assembly programs contained in this
application note have been fully tested and provide the
correct timing and 3-wire sequences to fully operate the
93LC56/66 in a PIC16CXX-based embedded application. The PIC16C54 was clocked at a 10MHz frequency.
This application note is intended to provide the engineer
with readily available stand-alone code modules to
accomplish all of the necessary functions to utilize these
devices in a low power application using the efficient
PIC16C54 microcontroller.
– Delay Routine
The 93 series of devices have essentially four I/O pins:
– Transmit Data Routine
CS
Chip Select
– Power-up Routine
CLK
Clock
– Erase/Write Enable Routine
DI
Data In
– Write Routine
DO
Data Out
– Erase/Write Disable Routine (EWDS)
– Start Bit Routine
– Bit Out Routine
– Transmit Data Routine
– Power-up Routine
– Erase/Write Enable Routine (EWEN)
– Byte Write Routine
– Erase/Write Disable Routine (EWDS)
3-Wire Byte Write with Data Polling Program
– Data Polling Delay Routine
– Start Bit Routine
– Bit Out Routine
This series of devices use a series of commands to
accomplish the normal memory functions. These are
READ, WRITE, EWEN, ERASE, ERAL, WRAL, EWDS.
For a more detailed discussion of the function of these
devices reference the appropriate data sheet and AN536,
also published by Microchip Technology.
3-Wire Sequential Read Program
The following programs are included in this application
note and are fully functional stand-alone modules. They
are intended for use by those who are not already
familiar with interfacing a PIC16CXX microcontroller to
a 93 series device. For those with more experience,
please refer to application note AN530.
– Receive Data Routine
– Delay Routine
– Start Bit Routine
– Bit In Routine
8
– Bit Out Routine
– Transmit Data Routine
– Power-up Routine
– Read Routine
3-Wire Byte Read Program
– Start Bit Routine
– Receive Data Routine
Author:
– Bit Out Routine
– Transmit Data Routine
Bruce Negley
Memory Products Division
– Power-up Routine
– Read Routine
© 1994 Microchip Technology Inc.
DS00560D-page 1
8-99
Using the 93LC56 and 93LC66
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
LIST P=16C54,c=132
;****************************************************************
;
3-Wire Byte Read Program (80 bytes)
;
;
This program demonstrates how to interface a
;
Microchip PIC16C54 to a 93LC56 or 93LC66 Serial EE
;
device. This program will read 8 consecutive addresses
;
in the ‘random read’ mode. This means that the opcode
;
and address for each byte will be sent to the device.
;
This program will repeat forever.
;
;
Another, more efficient method of reading consecutive
;
addresses is called the ‘sequential read’ mode. This
;
involves sending the opcode and address for the first
;
byte to read, then continuing to provide clocks for the
;
next addresses. The device will automatically increment
;
the address. An example of the sequential read mode is
;
provided in the ‘3wseqr.asm’ file.
;
;
This program communicates to the serial EE in the
;
x16 mode, and ASSUMES THE USER HAS SET THE ORG PIN
;
ON THE DEVICE TO Vcc.
;
;
Timing is based on using the PIC16C54 in ‘XT’ mode
;
using a 4Mhz crystal. Clock speeds to the serial EE
;
will be approximately 50 kHz for this setup.
;
;
PIC16C54 to Serial EE Connections:
;
;
PIC16C54
Serial EE
;
——————
——————
;
Pin 10 (RB4) —> Chip Select
;
Pin 11 (RB5) —> Clock
;
Pin 12 (RB6) —> Data In
;
Pin 13 (RB7) —> Data Out
;
ORG = Vcc
;
;************************************************************
;
Register Assignments
;************************************************************
status equ
3h
; status register
port_a equ
5h
; port 5 (port_a)
port_b equ
6h
; port 6 (port b) comm lines to serial EE
eeprom equ
0ah
; bit buffer
addr
equ
0ch
; address register
datai
equ
0dh
; stored data input reg.
datao
equ
0eh
; stored data output reg.
txbuf
equ
10h
; transmit buffer
count
equ
11h
; bits transmitted so far
bits
equ
12h
; bits to transmit
bytcnt equ
13h
; byte counter for read routine
0003
0005
0006
000A
000C
000D
000E
0010
0011
0012
0013
0052
0053
0054
0055
0056
0057
0058
0059
0060
PC
Page 1
Opcode
16c5x/7x Cross-Assembler V4.12 Released
Line
Mon Jun 06 10:49:10 1994
Mon Jun 06 10:49:10 1994
Page 2
Opcode
0015
0016
0017
0018
0007
0006
loops
equ
15h
; delay loop counter
loops2 equ
16h
; delay loop counter
hbyte
equ
17h
; high byte for input data
lbyte
equ
18h
; low byte for input data
;************************************************************
;
Bit Assignments
;************************************************************
di
equ
7
; eeprom input
do
equ
6
; eeprom output
DS00560D-page 2
© 1994 Microchip Technology Inc.
8-100
Using the 93LC56 and 93LC66
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0007
0006
0005
0004
0000
0000
0A33
0000
0A33
0001
0002
0003
0004
04C6
0486
04A6
0000
0005
0006
0007
0008
0586
05C6
0000
05A6
0009
000A
000B
000C
0000
0000
04A6
0800
000D
000E
000F
0010
0011
05EA
05A6
0000
07E6
04EA
01FF
datout equ
7
; data out line (port_b)
datin
equ
6
; data in line (port_b)
sclk
equ
5
; clock line (port_b)
chpsel equ
4
; chip select line (port_b)
;
;*************************************************************
org
01ffh
begin
goto
PWRUP
; set the reset vector
org
000h
goto
PWRUP
;
;**************************************************************
;
Start Bit Subroutine
;
this routine generates a start bit
;
(Chip select and DI high when clock goes high)
;**************************************************************
BSTART
bcf
port_b,datin
; set datain and chipselect lines
bcf
port_b,chpsel ; low just to check operation
bcf
port_b,sclk
; make sure clock starts low too.
nop
;
bsf
port_b,chpsel ; set chip select line high
bsf
port_b,datin
; set data in line high
nop
bsf
port_b,sclk
; set the clock line high to
; generate the start bit
nop
nop
bcf
port_b,sclk
; set clock low again
retlw
0
;
;**************************************************************
;
BITIN routine reads one bit of data from the
;
serial EE device and stores it in ‘di’
;**************************************************************
BITIN
bsf
eeprom,di
; assume input bit is high
bsf
port_b,sclk
; set clock line high
nop
;
btfss
port_b,datout ; read the data bit
bcf
eeprom,di
; input bit was low
16c5x/7x Cross-Assembler V4.12 Released
Mon Jun 06 10:49:10 1994
Line
PC
Opcode
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0012
04A6
bcf
port_b,sclk
0013
0800
retlw
0
0014
0015
0016
0017
0018
0019
001A
001B
001C
001D
001E
001F
006D
0C08
0031
0403
036D
090D
040D
06EA
050D
02F1
0A18
0800
Page 3
8
; set clock line low
;
;
;****************************************************************
;
Receive data routine
;
This routine reads one byte of data from the part
;
into the ‘datai’ register.
;****************************************************************
RX
clrf
datai
; clear input buffer
movlw
.8
; set # bits to 8
movwf
count
bcf
status,0
; make sure carry bit is low
RXLP
rlf
datai
; rotate the buffer left 1 bit
call
BITIN
; read 1 bit
bcf
datai,0
; assume the input bit was low
btfsc
eeprom,di
; check the bit
bsf
datai,0
; set high if neccessary
decfsz count
; 8 bits done?
goto
RXLP
; no, do another
retlw
0
© 1994 Microchip Technology Inc.
DS00560D-page 3
8-101
Using the 93LC56 and 93LC66
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0020
0021
0022
0023
07CA
0A24
05C6
0A25
0024
0025
0026
0027
0028
04C6
05A6
0000
04A6
0800
0029
002A
0212
0031
002B
04CA
;
;*************************************************************
;
BITOUT routine
;
This routine takes one bit of data in ‘do’ and
;
transmits it to the serial EE device
;*************************************************************
BITOUT
btfss
eeprom,do
; check state of data bit
goto
bitlow
; low, goto bitlow
bsf
port_b,datin
; high, set datain high
goto
clkout
; and clock it
;
bitlow
bcf
port_b,datin
; output a logic low
clkout
bsf
port_b,sclk
; set clock line high
nop
bcf
port_b,sclk
; return clock line low
retlw
0
;
;****************************************************************
;
Transmit Data Subroutine
;
This routine takes the byte of data stored in the
;
‘datao’ register and transmits it to the serial EE device.
;****************************************************************
TX
movf
bits,w
; set the number of bits to xmit
movwf
count
;
TXLP
bcf
eeprom,do
; assume bit 7 is low
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
Opcode
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
002C
002D
002E
002F
0030
0031
0032
06F0
05CA
0920
0370
02F1
0A2B
0800
0033
0034
0035
0C00
0005
0065
0036
0037
0C80
0006
0038
0039
0C00
002C
btfsc
bsf
call
rlf
decfsz
goto
retlw
Mon Jun 06 10:49:10 1994
txbuf,7
eeprom,do
BITOUT
txbuf
count
TXLP
0
;
;
;
;
;
;
;
Page 4
is bit 7 clear?
no, set data bit =1
transmit 1 bit to serial EE
rotate txbuf left
all bits done?
no, do another bit
yes, jump out
;
;****************************************************************
;
POWER-UP ROUTINE
;
This is the program entry point, which in this case simply
;
sets the port_a I/O lines and directs control to the
;
read routine.
;*****************************************************************
PWRUP
;
movlw
b’00000000'
tris
port_a
; set port_a as all output
clrf
port_a
; all lines low
movlw
tris
b’10000000'
port_b
; set RB7 as input, rest output;
;
;
Fall through and do the read
;
;*********************************************************************
;
READ ROUTINE
;
This routine reads 8 consecutive addresses in
;
random mode starting at address 0. This is done in
;
x16 mode and will repeat forever.
;*********************************************************************
READ
;
movlw
.0
; set starting address to 00
movwf
addr
;
DS00560D-page 4
© 1994 Microchip Technology Inc.
8-102
Using the 93LC56 and 93LC66
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
003A
003B
0C08
0033
003C
003D
003E
003F
0040
0041
0042
0043
0044
0045
0046
0901
0C02
0032
0C80
0030
0929
0C08
0032
020C
0030
0929
0047
0914
rbyte
movlw
movwf
.8
bytcnt
call
movlw
movwf
movlw
movwf
call
movlw
movwf
movf
movwf
call
BSTART
.2
bits
b’10000000'
txbuf
TX
.8
bits
addr,w
txbuf
TX
;
;
;
;
;
;
;
;
;
;
;
;
;
;
call
RX
; read the high byte
16c5x/7x Cross-Assembler V4.12 Released
set number of addresses to
read as 8
generate the start bit
set # bits to 2
get opcode (10b)
into output buffer
and transmit it
set number of bits to 8
get the address
into the output buffer
and transmit it
Mon Jun 06 10:49:10 1994
Page 5
Line
PC
Opcode
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0048
0049
020D
0037
movf
movwf
datai,w
hbyte
; move input data to w
; xfer it to high byte
004A
004B
004C
0914
020D
0037
call
movf
movwf
RX
datai,w
hbyte
; read the low byte
; move input data to w
; xfer it to low byte
004D
0486
bcf
port_b,chpsel
; clear the chip select line
004E
004F
0050
0051
02AC
02F3
0A3C
0A38
0000
incf
decfsz
goto
goto
addr
bytcnt
rbyte
READ
;
;
;
;
add 1 to the address
have all bytes been read?
no, read another byte
yes, start over
END
8
© 1994 Microchip Technology Inc.
DS00560D-page 5
8-103
Using the 93LC56 and 93LC66
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
LIST P=16C54,c=132
;****************************************************************
;
3-Wire Byte Write Program (106 bytes)
;
;
This program demonstrates how to interface a
;
Microchip PIC16C54 to a 93LC56 or 93LC66 Serial EE
;
device. This program will execute the erase/write enable
;
command, write to 8 consecutive addresses, and then
;
execute the erase/write disable command. This
;
sequence will repeat forever.
;
;
After each byte is written, time must be given to the
;
device for it to complete the write cycle before
;
the next command can be sent. The easiest solution
;
is to consult the data book for the maximum write
;
cycle time and just wait that long before the next
;
command is sent. This program demonstrates that
;
solution.
;
;
Another, more efficient method of determining when the
;
write cycle is complete is called ‘data polling.’ This
;
method is demonstrated in the program “3wdpoll.”
;
;
This program communicates to the serial EE in the
;
x16 mode, and ASSUMES THE USER HAS SET THE ORG PIN
;
ON THE DEVICE TO Vcc.
;
;
Timing is based on using the PIC16C54 in ‘XT’ mode
;
using a 4Mhz crystal. Clock speeds to the serial EE
;
will be approximately 40 kHz for this setup.
;
;
PIC16C54 to Serial EE Connections:
;
;
PIC16C54
Serial EE
;
——————
——————
;
Pin 10 (RB4) —> Chip Select
;
Pin 11 (RB5) —> Clock
;
Pin 12 (RB6) —> Data In
;
Pin 13 (RB7) —> Data Out
;
ORG=Vcc
;
;************************************************************
;
Register Assignments
;************************************************************
port_a equ
5h
; port 5 (port_a)
port_b equ
6h
; port 6 (port b) comm lines to serial EE
eeprom equ
0ah
; bit buffer
addr
equ
0ch
; address register
datai
equ
0dh
; stored data input reg.
datao
equ
0eh
; stored data output reg.
txbuf
equ
10h
; transmit buffer
0005
0006
000A
000C
000D
000E
0010
0052
0053
0054
0055
0056
0057
0058
0059
0060
PC
Page 1
Opcode
16c5x/7x Cross-Assembler V4.12 Released
Line
Mon Jun 06 10:49:06 1994
Mon Jun 06 10:49:06 1994
Page 2
Opcode
0011
0012
0013
0015
0016
0007
count
equ
11h
; bits transmitted so far
bits
equ
12h
; bits to transmit
bytcnt equ
13h
; byte counter for write routine
loops
equ
15h
; delay loop counter
loops2 equ
16h
; delay loop counter
;
;************************************************************
;
Bit Assignments
;************************************************************
di
equ
7
; eeprom input
DS00560D-page 6
© 1994 Microchip Technology Inc.
8-104
Using the 93LC56 and 93LC66
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0006
0007
0006
0005
0004
0000
0000
0A2F
0000
0A2F
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
0C6E
0036
0000
0000
0000
0000
0000
0000
02F6
0A03
000B
000C
000D
02F5
0A01
0800
000E
0C8F
01FF
do
equ
6
; eeprom output
datout equ
7
; data out line (port_b)
datin
equ
6
; data in line (port_b)
sclk
equ
5
; clock line (port_b)
chpsel equ
4
; chip select line (port_b)
;
;*************************************************************
org
01ffh
begin
goto
PWRUP
; set the reset vector
org
000h
goto
PWRUP
;
;*************************************************************
;
DELAY ROUTINE
;
This routine takes the value in ‘loops’
;
and multiplies it times 1 millisecond to
;
determine delay time.
;*************************************************************
WAIT
;
top
movlw
.110
; timing adjustment variable
movwf
loops2
top2
nop
; sit and wait
nop
nop
nop
nop
nop
decfsz loops2
; inner loops complete?
goto
top2
; no, go again
;
decfsz loops
; outer loops complete?
goto
top
; no, go again
retlw
0
; yes, return from sub
;
;**************************************************************
;
Start Bit Subroutine
;
this routine generates a start bit
;
(Chip select and DI high when clock goes high)
;**************************************************************;
BSTART
movlw
b’10001111'
16c5x/7x Cross-Assembler V4.12 Released
Mon Jun 06 10:49:06 1994
Page 3
Line
PC
Opcode
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
000F
0006
tris
port_b
0010
0011
0012
0013
04C6
0486
04A6
0000
bcf
bcf
bcf
nop
port_b,datin
port_b,chpsel
port_b,sclk
;
;
;
;
;
0014
0015
0016
0017
0586
05C6
0000
05A6
bsf
bsf
nop
bsf
port_b,chpsel
port_b,datin
; set chip select line high
; set data in line high
port_b,sclk
; set the clock line high to
; generate the start bit
0018
0019
001A
001B
0000
0000
04A6
0800
set port b for output
except for the data out line
set datain and chipselect lines
low just to check operation
make sure clock starts low too.
;
nop
nop
bcf
port_b,sclk
; set clock low again
retlw
0
;
;*************************************************************
;
BITOUT routine
;
This routine takes one bit of data in ‘do’ and
;
transmits it to the serial EE device
;*************************************************************
© 1994 Microchip Technology Inc.
DS00560D-page 7
8-105
8
Using the 93LC56 and 93LC66
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
BITOUT
001C
001D
001E
001F
07CA
0A20
05C6
0A21
0020
0021
0022
0023
0024
04C6
05A6
0000
04A6
0800
0025
0026
0212
0031
0027
0028
0029
002A
002B
002C
002D
04CA
06F0
05CA
091C
0370
02F1
0A27
bitlow
clkout
btfss
goto
bsf
goto
eeprom,do
bitlow
port_b,datin
clkout
bcf
bsf
nop
bcf
retlw
port_b,datin
port_b,sclk
port_b,sclk
0
;
;
;
;
;
;
;
check state of data bit
low, goto bitlow
high, set datain high
and clock it
output a logic low
set clock line high
; return clock line low
;
;****************************************************************
;
Transmit Data Subroutine
;
This routine takes the byte of data stored in the
;
‘datao’ register and transmits it to the serial EE device.
;****************************************************************
TX
movf
bits,w
; set the number of bits to xmit
movwf
count
;
TXLP
bcf
eeprom,do
; assume bit 7 is low
btfsc
txbuf,7
; is bit 7 clear?
bsf
eeprom,do
; no, set data bit =1
call
BITOUT
; transmit 1 bit to serial EE
rlf
txbuf
; rotate txbuf left
decfsz count
; all bits done?
goto
TXLP
; no, do another bit
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
Opcode
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
002E
0800
002F
0030
0031
0C00
0005
0065
0032
0033
0C80
0006
0034
090E
0035
0036
0037
0038
0039
003A
0C02
0032
0C00
0030
0925
0C08
Mon Jun 06 10:49:06 1994
Page 4
retlw
0
; yes, jump out
;
;****************************************************************
;
POWER-UP ROUTINE
;
This is the program entry point, which in this case simply
;
sets the port_a I/O lines and directs control to the
;
erase/write enable routine.
;*****************************************************************
PWRUP
;
movlw
b’00000000'
tris
port_a
; set port_a as all output
clrf
port_a
; all lines low
movlw
tris
b’10000000'
port_b
; set RB7 as input, rest output;
;
;
Fall through and do erase/write enable
;
;****************************************************************
;
EWEN (Erase/Write ENable Routine)
;
this routine enables the dut for erasing and
;
writing. This must be done prior to any erase,write
;
eral,wral instructions.
;****************************************************************
EWEN
;
call
BSTART
; generate a start bit
;
movlw
.2
; set # bits to 2
movwf
bits
;
movlw
b’00000000'
; get the opcode (00b)
movwf
txbuf
; into the output buffer
call
TX
; and transmit it
movlw
.8
; set # bits to 8
DS00560D-page 8
© 1994 Microchip Technology Inc.
8-106
Using the 93LC56 and 93LC66
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
003B
003C
0032
0CC0
movwf
movlw
bits
b’11000000'
003D
003E
003F
0040
0030
0925
0486
0000
movwf
call
bcf
nop
txbuf
TX
port_b,chpsel
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
get opcode and address
(11XXXXXX)
into output buffer
and transmit it
set chip select line low
;
;
Now continue on to the write command
;
;**************************************************************
;
Byte Write Routine
;
This routine writes an AA55h pattern into
;
8 consecutive addresses starting at address 00.
;
A delay of about 10ms is given after each byte
;
for the write cycle to complete.
16c5x/7x Cross-Assembler V4.12 Released
Line
;
;
;
;
;
;
PC
Mon Jun 06 10:49:06 1994
Page 5
Opcode
0041
0042
0043
0044
0C00
002C
0C08
0033
0045
090E
0046
0047
0048
0049
004A
0C02
0032
0C40
0030
0925
004B
004C
004D
004E
004F
0050
0051
0052
0053
0054
0055
0C08
0032
020C
0030
0925
0CAA
0030
0925
0C55
0030
0925
0056
0486
0057
0058
0059
0C0A
0035
0901
005A
005B
005C
02AC
02F3
0A45
;
The write is done in the x16 mode: the user must
;
have the ORG pin tied to Vcc on the device
;****************************************************************
WRITE
;
movlw
.0
; set starting address to 00
movwf
addr
;
movlw
.8
; set number of bytes to write as 8
movwf
bytcnt
;
;
topwr
call
BSTART
; generate the start bit
;
movlw
.2
; set # bits to 2 for the opcode
movwf
bits
;
movlw
b’01000000'
; get opcode (01b)
movwf
txbuf
; into the transmit buffer
call
TX
; and send it
;
movlw
.8
; set # of bits to 8 for the
movwf
bits
; address
movf
addr,w
; get address counter
movwf
txbuf
; into output buffer
call
TX
; and send it
movlw
b’10101010'
; get upper byte of data (AAh)
movwf
txbuf
; into the transmit buffer
call
TX
; and send it
movlw
b’01010101'
; get lower byte of data (55h)
movwf
txbuf
; into transmit buffer
call
TX
; and send it
;
bcf
port_b,chpsel ; clear the chip select line
; to initiate write cycle
;
movlw
.10
;
movwf
loops
; set delay time to 10mS
call
WAIT
; and wait
;
incf
addr
; increment address counter
decfsz bytcnt
; all bytes written?
goto
topwr
; no, do another
; yes, go on
;
;
Now continue on to the erase/write disable command
;
;****************************************************************
;
EWDS (Erase/Write Disable Routine)
;
This routine executes the erase/write disable command
;
which prevents the contents of the array from being
© 1994 Microchip Technology Inc.
DS00560D-page 9
8-107
8
Using the 93LC56 and 93LC66
0253
0254
0255
;
written to.
;
;****************************************************************
16c5x/7x Cross-Assembler V4.12 Released
Line
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
PC
Mon Jun 06 10:49:06 1994
Page 6
Opcode
EWDS
;
005D
090E
call
BSTART
; generate a start bit
;
005E
005F
0060
0061
0062
0063
0064
0065
0C02
0032
0C00
0030
0925
0C08
0032
0C00
movlw
movwf
movlw
movwf
call
movlw
movwf
movlw
.2
bits
b’00000000'
txbuf
TX
.8
bits
b’00000000'
0066
0067
0068
0069
006A
0030
0925
0486
0000
0A34
movwf
call
bcf
nop
goto
txbuf
TX
port_b,chpsel
;
;
;
;
;
;
;
;
;
;
;
;
EWEN
; start all over
0000
set # bits to 2
get the opcode (00b)
into the output buffer
and transmit it
set # bits to 8
get opcode and address
(00XXXXXX)
into output buffer
and transmit it
set chip select line low
;
END
DS00560D-page 10
© 1994 Microchip Technology Inc.
8-108
Using the 93LC56 and 93LC66
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
LIST P=16C54,c=132
;****************************************************************
;
3-Wire Byte Write with Data Poll Program (107 bytes)
;
;
This program demonstrates how to interface a
;
Microchip PIC16C54 to a 93LC56 or 93LC66 Serial EE
;
device. This program will execute the erase/write enable
;
command, write to 8 consecutive addresses, and then
;
use the ‘data polling’ method to determine when the
;
write cycle is complete. The program then executes
;
the erase/write disable command. This sequence will
;
repeat forever.
;
;
When writing to a 3-wire serial EE device, the
;
internally timed write cycle will begin after
;
the opcode, address and data are sent to the
;
device. There are two ways to make sure that the
;
cycle is complete before you send it another command.
;
The simplest method is to simply wait for the maximum
;
write cycle time, which can be obtained from the data book.
;
A more efficient method is “Data polling.” This is
;
done by toggling the chip select line low and then
;
back high after the opcode, address and data are sent.
;
The chip select line must be low for at least 250ns
;
before bringing it high again. The device will pull
;
the data out line low at that point, and set it high
;
when the write cycle is complete. The user can then check
;
or “poll” the dataout line until it goes high before
;
sending the next command.
;
;
As an option, the user can connect a LED to pin 18
;
on the PIC16C54 (use about a 1K resistor in series) as a
;
timeout indicator. This LED will come on if the
;
data polling is unsuccessful and the device being
;
programmed does not respond. This can be tested by
;
simply running the program with no part in the socket.
;
;
This program communicates to the serial EE in the
;
x16 mode, and ASSUMES THE USER HAS SET THE ORG PIN
;
ON THE DEVICE TO Vcc.
;
;
Timing is based on using the PIC16C54 in ‘XT’ mode
;
using a 4Mhz crystal. Clock speeds to the serial EE
;
will be approximately 50 kHz for this setup.
;
;
PIC16C54 to Serial EE Connections:
;
;
PIC16C54
Serial EE
;
——————
——————
;
Pin 10 (RB4) —> Chip Select
;
Pin 11 (RB5) —> Clock
16c5x/7x Cross-Assembler V4.12 Released
0052
0053
0054
0055
0056
0057
0058
0059
0060
Page 1
Opcode
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
Line
Mon Jun 06 10:49:00 1994
PC
Mon Jun 06 10:49:00 1994
Page 2
Opcode
0005
0006
;
Pin 12 (RB6) —> Data In
;
Pin 13 (RB7) —> Data Out
;
ORG=Vcc
;
;************************************************************
;
Register Assignments
;************************************************************
port_a equ
5h
; port 5 (port_a)
port_b equ
6h
; port 6 (port b) used comm lines to serial EE
© 1994 Microchip Technology Inc.
DS00560D-page 11
8-109
8
Using the 93LC56 and 93LC66
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
000A
000C
000D
000E
0010
0011
0012
0013
0015
0016
0007
0006
0007
0006
0005
0004
0001
eeprom equ
0ah
; bit buffer
addr
equ
0ch
; address register
datai
equ
0dh
; stored data input reg.
datao
equ
0eh
; stored data output reg.
txbuf
equ
10h
; transmit buffer
count
equ
11h
; bits transmitted so far
bits
equ
12h
; bits to transmit
bytcnt equ
13h
; byte counter for write routine
loops
equ
15h
; delay loop counter
loops2 equ
16h
; delay loop counter
;************************************************************
;
Bit Assignments
;************************************************************
di
equ
7
; eeprom input
do
equ
6
; eeprom output
datout equ
7
; data out line (port_b)
datin
equ
6
; data in line (port_b)
sclk
equ
5
; clock line (port_b)
chpsel equ
4
; chip select line (port_b)
timeout equ
1
; write cycle timeout warning (port_a)
;
;*************************************************************
org
01ffh
begin
goto
PWRUP
; set the reset vector
org
000h
goto
PWRUP
;
;*************************************************************
;
DATA POLL DELAY ROUTINE
;
This routine delays 100 us is
;
used for delay between polls
;*************************************************************
dpdelay
;
movlw
.25
; timing adjustment variable
movwf
loops2
top
nop
decfsz loops2
; loops complete?
goto
top
; no, go again
;
retlw
0
; yes, return from sub
;
0000
0000
0A26
0000
0A26
0001
0002
0003
0004
0005
0C19
0036
0000
02F6
0A03
0006
0800
01FF
16c5x/7x Cross-Assembler V4.12 Released
Line
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
PC
Mon Jun 06 10:49:00 1994
Page 3
Opcode
0007
0008
0009
000A
04C6
0486
04A6
0000
000B
000C
000D
000E
0586
05C6
0000
05A6
000F
0010
0011
0012
0000
0000
04A6
0800
;**************************************************************
;
Start Bit Subroutine
;
this routine generates a start bit
;
(Chip select and DI high when clock goes high)
;**************************************************************;
BSTART
bcf
port_b,datin
; set datain and chipselect lines
bcf
port_b,chpsel ; low just to check operation
bcf
port_b,sclk
; make sure clock starts low too.
nop
;
bsf
port_b,chpsel ; set chip select line high
bsf
port_b,datin
; set data in line high
nop
bsf
port_b,sclk
; set the clock line high to
; generate the start bit
nop
nop
bcf
port_b,sclk
; set clock low again
retlw
0
;
;*************************************************************
DS00560D-page 12
© 1994 Microchip Technology Inc.
8-110
Using the 93LC56 and 93LC66
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0013
0014
0015
0016
07CA
0A17
05C6
0A18
0017
0018
0019
001A
001B
04C6
05A6
0000
04A6
0800
001C
001D
0212
0031
001E
001F
0020
04CA
06F0
05CA
;
BITOUT routine
;
This routine takes one bit of data in ‘do’ and
;
transmits it to the serial EE device
;*************************************************************
BITOUT
btfss
eeprom,do
; check state of data bit
goto
bitlow
; low, goto bitlow
bsf
port_b,datin
; high, set datain high
goto
clkout
; and clock it
;
bitlow
bcf
port_b,datin
; output a logic low
clkout
bsf
port_b,sclk
; set clock line high
nop
bcf
port_b,sclk
; return clock line low
retlw
0
;
;****************************************************************
;
Transmit Data Subroutine
;
This routine takes the byte of data stored in the
;
‘datao’ register and transmits it to the serial EE device.
;****************************************************************
TX
movf
bits,w
; set the number of bits to xmit
movwf
count
;
TXLP
bcf
eeprom,do
; assume bit 7 is low
btfsc
txbuf,7
; is bit 7 clear?
bsf
eeprom,do
; no, set data bit =1
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
Opcode
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0021
0022
0023
0024
0025
0913
0370
02F1
0A1E
0800
0026
0027
0028
0C00
0005
0065
0029
002A
0C80
0006
002B
0907
002C
002D
0C02
0032
call
rlf
decfsz
goto
retlw
Mon Jun 06 10:49:00 1994
BITOUT
txbuf
count
TXLP
0
;
;
;
;
;
Page 4
transmit 1 bit to serial EE
rotate txbuf left
all bits done?
no, do another bit
yes, jump out
;
;****************************************************************
;
POWER-UP ROUTINE
;
This is the program entry point, which in this case simply
;
sets the port_a I/O lines and directs control to the
;
erase/write enable routine.
;*****************************************************************
PWRUP
;
movlw
b’00000000'
tris
port_a
; set port_a as all output
clrf
port_a
; all lines low
movlw
tris
b’10000000'
port_b
; set RB7 as input, rest output;
;
;
Fall through and do erase/write enable
;
;****************************************************************
;
EWEN (Erase/Write ENable Routine)
;
this routine enables the dut for erasing and
;
writing. This must be done prior to any erase,write
;
eral,wral instructions.
;****************************************************************
EWEN
;
call
BSTART
; generate a start bit
;
movlw
.2
; set # bits to 2
movwf
bits
;
© 1994 Microchip Technology Inc.
DS00560D-page 13
8-111
8
Using the 93LC56 and 93LC66
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
002E
002F
0030
0031
0032
0033
0C00
0030
091C
0C08
0032
0CC0
movlw
movwf
call
movlw
movwf
movlw
b’00000000'
txbuf
TX
.8
bits
b’11000000'
0034
0035
0036
0037
0030
091C
0486
0000
movwf
call
bcf
nop
txbuf
TX
port_b,chpsel
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
get the opcode (00b)
into the output buffer
and transmit it
set # bits to 8
get opcode and address
(11XXXXXX)
into output buffer
and transmit it
set chip select line low
;
;
Now continue on to the write command
;
;**************************************************************
;
WRITE
16c5x/7x Cross-Assembler V4.12 Released
Line
;
;
;
;
;
;
;
;
;
;
PC
Mon Jun 06 10:49:00 1994
Page 5
Opcode
0038
0039
003A
003B
0C00
002C
0C08
0033
003C
0907
003D
003E
003F
0040
0041
0C02
0032
0C40
0030
091C
0042
0043
0044
0045
0046
0047
0048
0049
004A
004B
004C
0C08
0032
020C
0030
091C
0CAA
0030
091C
0C55
0030
091C
004D
0486
004E
004F
0000
0586
0050
0051
0052
0053
0054
0055
0CC8
0035
0901
06E6
0A59
02F5
;
This routine writes a AA55h pattern into
;
8 consecutive addresses starting at address 00.
;
It will then ‘poll’ the data out line to determine
;
when the write cycle is complete. If the cycle has
;
not completed within 20 ms, then it will continue
;
anyway and turn the timeout fail LED on.
;
The write is done in the x16 mode: the user must
;
have the ORG pin tied to Vcc on the device. This
;
program will repeat forever.
;****************************************************************
WRITE
;
movlw
.0
; set starting address to 00
movwf
addr
;
movlw
.8
; set number of bytes to write as 8
movwf
bytcnt
;
;
topwr
call
BSTART
; generate the start bit
;
movlw
.2
; set # bits to 2 for the opcode
movwf
bits
;
movlw
b’01000000'
; get opcode (01b)
movwf
txbuf
; into the transmit buffer
call
TX
; and send it
;
movlw
.8
; set # of bits to 8 for the
movwf
bits
; address
movf
addr,w
; get address counter
movwf
txbuf
; into output buffer
call
TX
; and send it
movlw
b’10101010'
; get first half of data (AAh)
movwf
txbuf
; into the transmit buffer
call
TX
; and send it
movlw
b’01010101'
; get second half of data (55h)
movwf
txbuf
; into transmit buffer
call
TX
; and send it
;
bcf
port_b,chpsel ; clear the chip select line
; to initiate write cycle
nop
bsf
port_b,chpsel ; set the chip sel line high
; to begin data polling
movlw
.200
;
movwf
loops
; poll 100 times before timeout(about 20ms)
polltop call
dpdelay
; wait 100us
btfsc
port_b,datout ; is the data out line high?
goto
okpoll
; yes-cycle complete: do another
decfsz loops
; has it timed out?
DS00560D-page 14
© 1994 Microchip Technology Inc.
8-112
Using the 93LC56 and 93LC66
0253
0254
0255
0056
0057
0058
0A52
0525
0A5A
goto
bsf
goto
polltop
; no, check again
port_a,timeout; yes, set timeout LED and go on
badpoll
;
16c5x/7x Cross-Assembler V4.12 Released
Line
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
PC
Opcode
0059
005A
005B
005C
005D
0425
0486
02AC
02F3
0A3C
005E
0907
005F
0060
0061
0062
0063
0064
0065
0066
0C02
0032
0C00
0030
091C
0C08
0032
0C00
0067
0068
0069
006A
006B
0030
091C
0486
0000
0A2B
0000
okpoll
badpoll
bcf
bcf
incf
decfsz
goto
Mon Jun 06 10:49:00 1994
port_a,timeout;
port_b,chpsel ;
addr
;
bytcnt
;
topwr
;
;
Page 6
clear the timeout LED
chip sel line back low
increment address counter
all bytes written?
no, do another
yes, go on
;
;
Now continue on to the erase/write disable command
;
;****************************************************************
;
EWDS (Erase/Write Disable Routine)
;
This routine executes the erase/write disable command
;
which prevents the contents of the array from being
;
written to.
;
;****************************************************************
EWDS
;
call
BSTART
; generate a start bit
;
movlw
.2
; set # bits to 2
movwf
bits
;
movlw
b’00000000'
; get the opcode (00b)
movwf
txbuf
; into the output buffer
call
TX
; and transmit it
movlw
.8
; set # bits to 8
movwf
bits
;
movlw
b’00000000'
; get opcode and address
;
(00XXXXXX)
movwf
txbuf
; into output buffer
call
TX
; and transmit it
bcf
port_b,chpsel ; set chip select line low
nop
goto
EWEN
; start all over
;
;
END
8
© 1994 Microchip Technology Inc.
DS00560D-page 15
8-113
Using the 93LC56 and 93LC66
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
LIST P=16C54,c=132
;****************************************************************
;
3-Wire Sequential Read Program (93 bytes)
;
;
This program demonstrates how to interface a
;
Microchip PIC16C54 to a 93LC56 or 93LC66 Serial EE
;
device. This program will read 8 consecutive addresses
;
in the ‘sequential read’ mode. This means that the opcode
;
and address are sent for the first address only. After
;
the first address is read, the Chip Select line is left
;
high and clocks for the remaining 7 bytes are sent to the
;
device. The device will automatically increment the address
;
pointer in this mode, allowing the user to read as many
;
consecutive addresses as needed. This program will repeat
;
forever.
;
;
This program communicates to the serial EE in the
;
x16 mode, and ASSUMES THE USER HAS SET THE ORG PIN
;
ON THE DEVICE TO Vcc.
;
;
Timing is based on using the PIC16C54 in ‘XT’ mode
;
using a 4MHz crystal. Clock speeds to the serial EE
;
will be approximately 50 kHz for this setup.
;
;
PIC16C54 to Serial EE Connections:
;
;
PIC16C54
Serial EE
;
——————
——————
;
Pin 10 (RB4) —> Chip Select
;
Pin 11 (RB5) —> Clock
;
Pin 12 (RB6) —> Data In
;
Pin 13 (RB7) —> Data Out
;
ORG = Vcc
;
;************************************************************
;
Register Assignments
;************************************************************
status equ
3h
; status register
port_a equ
5h
; port 5 (port_a)
port_b equ
6h
; port 6 (port b) used comm lines to serial EE
eeprom equ
0ah
; bit buffer
addr
equ
0ch
; address register
datai
equ
0dh
; stored data input reg.
datao
equ
0eh
; stored data output reg.
txbuf
equ
10h
; transmit buffer
count
equ
11h
; bits transmitted so far
bits
equ
12h
; bits to transmit
bytcnt equ
13h
; byte counter for read routine
loops
equ
15h
; delay loop counter
loops2 equ
16h
; delay loop counter
hbyte
equ
17h
; high byte for input data
0003
0005
0006
000A
000C
000D
000E
0010
0011
0012
0013
0015
0016
0017
0052
0053
0054
0055
0056
0057
0058
0059
0060
PC
Page 1
Opcode
16c5x/7x Cross-Assembler V4.12 Released
Line
Mon Jun 06 10:49:20 1994
Mon Jun 06 10:49:20 1994
Page 2
Opcode
0018
0007
0006
0007
0006
0005
lbyte
equ
18h
; low byte for input data
;************************************************************
;
Bit Assignments
;************************************************************
di
equ
7
; eeprom input
do
equ
6
; eeprom output
datout equ
7
; data out line (port_b)
datin
equ
6
; data in line (port_b)
sclk
equ
5
; clock line (port_b)
DS00560D-page 16
© 1994 Microchip Technology Inc.
8-114
Using the 93LC56 and 93LC66
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0004
0000
0000
0A40
0000
0A40
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
0C6E
0036
0000
0000
0000
0000
0000
0000
02F6
0A03
000B
000C
000D
02F5
0A01
0800
000E
000F
0010
0011
04C6
0486
04A6
0000
01FF
chpsel equ
4
; chip select line (port_b)
;
;*************************************************************
org
01ffh
begin
goto
PWRUP
; set the reset vector
org
000h
goto
PWRUP
;
;*************************************************************
;
DELAY ROUTINE
;
This routine takes the value in ‘loops’
;
and multiplies it times 1 millisecond to
;
determine delay time.
;*************************************************************
WAIT
;
top
movlw
.110
; timing adjustment variable
movwf
loops2
top2
nop
; sit and wait
nop
nop
nop
nop
nop
decfsz loops2
; inner loops complete?
goto
top2
; no, go again
;
decfsz loops
; outer loops complete?
goto
top
; no, go again
retlw
0
; yes, return from sub
;
;**************************************************************
;
Start Bit Subroutine
;
this routine generates a start bit
;
(Chip select and DI high when clock goes high)
;**************************************************************
BSTART
bcf
port_b,datin
; set datain and chipselect lines
bcf
port_b,chpsel ; low just to check operation
bcf
port_b,sclk
; make sure clock starts low too.
nop
;
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
Opcode
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0012
0013
0014
0015
0586
05C6
0000
05A6
0016
0017
0018
0019
0000
0000
04A6
0800
001A
001B
001C
001D
001E
001F
05EA
05A6
0000
07E6
04EA
04A6
bsf
bsf
nop
bsf
Mon Jun 06 10:49:20 1994
Page 3
port_b,chpsel
port_b,datin
; set chip select line high
; set data in line high
port_b,sclk
; set the clock line high to
; generate the start bit
8
nop
nop
bcf
port_b,sclk
; set clock low again
retlw
0
;
;**************************************************************
;
BITIN routine reads one bit of data from the
;
serial EE device and stores it in ‘di’
;**************************************************************
BITIN
bsf
eeprom,di
; assume input bit is high
bsf
port_b,sclk
; set clock line high
nop
;
btfss
port_b,datout ; read the data bit
bcf
eeprom,di
; input bit was low
bcf
port_b,sclk
; set clock line low
;
© 1994 Microchip Technology Inc.
DS00560D-page 17
8-115
Using the 93LC56 and 93LC66
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0020
0800
0021
0022
0023
0024
0025
0026
0027
0028
0029
002A
002B
002C
006D
0C08
0031
0403
036D
091A
040D
06EA
050D
02F1
0A25
0800
002D
002E
07CA
0A31
retlw
0
16c5x/7x Cross-Assembler V4.12 Released
Line
PC
Opcode
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
002F
0030
05C6
0A32
0031
0032
0033
0034
0035
04C6
05A6
0000
04A6
0800
0036
0037
0212
0031
0038
0039
003A
003B
003C
003D
003E
003F
04CA
06F0
05CA
092D
0370
02F1
0A38
0800
;
;****************************************************************
;
Receive data routine
;
This routine reads one byte of data from the part
;
into the ‘datai’ register.
;****************************************************************
RX
clrf
datai
; clear input buffer
movlw
.8
; set # bits to 8
movwf
count
bcf
status,0
; make sure carry bit is low
RXLP
rlf
datai
; rotate the buffer left 1 bit
call
BITIN
; read 1 bit
bcf
datai,0
; assume the input bit was low
btfsc
eeprom,di
; check the bit
bsf
datai,0
; set high if necessary
decfsz count
; 8 bits done?
goto
RXLP
; no, do another
retlw
0
;
;*************************************************************
;
BITOUT routine
;
This routine takes one bit of data in ‘do’ and
;
transmits it to the serial EE device
;*************************************************************
BITOUT
btfss
eeprom,do
; check state of data bit
goto
bitlow
; low, goto bitlow
bitlow
clkout
Mon Jun 06 10:49:20 1994
bsf
goto
port_b,datin
clkout
bcf
bsf
nop
bcf
retlw
port_b,datin
port_b,sclk
port_b,sclk
0
;
;
;
;
;
Page 4
high, set datain high
and clock it
output a logic low
set clock line high
; return clock line low
;
;****************************************************************
;
Transmit Data Subroutine
;
This routine takes the byte of data stored in the
;
‘datao’ register and transmits it to the serial EE device.
;****************************************************************
TX
movf
bits,w
; set the number of bits to xmit
movwf
count
;
TXLP
bcf
eeprom,do
; assume bit 7 is low
btfsc
txbuf,7
; is bit 7 clear?
bsf
eeprom,do
; no, set data bit =1
call
BITOUT
; transmit 1 bit to serial EE
rlf
txbuf
; rotate txbuf left
decfsz count
; all bits done?
goto
TXLP
; no, do another bit
retlw
0
; yes, jump out
;
;****************************************************************
;
POWER-UP ROUTINE
;
This is the program entry point, which in this case simply
;
sets the port_a I/O lines and directs control to the
;
erase/write enable routine.
;*****************************************************************
PWRUP
DS00560D-page 18
© 1994 Microchip Technology Inc.
8-116
Using the 93LC56 and 93LC66
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
;
0040
0041
0042
0043
0044
0C11
0005
0065
0C80
0006
movlw
tris
clrf
movlw
tris
b’00010001'
port_a
port_a
b’10000000'
port_b
; set RB7 as input, rest output;
;
;
Fall through and do the read
;
;*********************************************************************
;
READ ROUTINE (Sequential read mode)
;
This routine reads 8 consecutive addresses in
;
sequential mode starting at address 0. This
;
program will repeat forever
;*********************************************************************
READ
16c5x/7x Cross-Assembler V4.12 Released
Line
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
; set RA0 as input, rest output
; all lines low
Mon Jun 06 10:49:20 1994
Page 5
PC
Opcode
0045
0046
0047
0048
0C00
002C
0C08
0033
movlw
movwf
movlw
movwf
.0
addr
.8
bytcnt
0049
004A
004B
004C
004D
004E
004F
0050
0051
0052
0053
090E
0C02
0032
0C80
0030
0936
0C08
0032
020C
0030
0936
call
movlw
movwf
movlw
movwf
call
movlw
movwf
movf
movwf
call
BSTART
.2
bits
b’10000000'
txbuf
TX
.8
bits
addr,w
txbuf
TX
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
0054
0055
0056
0921
020D
0037
call
movf
movwf
RX
datai,w
hbyte
; read the high byte
; move input data to w
; xfer it to high byte
0057
0058
0059
0921
020D
0037
call
movf
movwf
RX
datai,w
hbyte
; read the low byte
; move input data to w
; xfer it to low byte
005A
005B
005C
02AC
02F3
0A54
incf
decfsz
goto
addr
bytcnt
rbyte
; add 1 to the address
; have all bytes been read?
; no, read another byte
005D
005E
0486
0A45
0000
bcf
goto
port_b,chpsel
READ
; yes,clear the chip select line
; and start over
;
rbyte
set starting address to 00
set number of addresses to
read as 8
generate the start bit
set # bits to 2
get opcode (10b)
into output buffer
and transmit it
set number of bits to 8
get the address
into the output buffer
and transmit it
8
END
© 1994 Microchip Technology Inc.
DS00560D-page 19
8-117
Using the 93LC56 and 93LC66
NOTES:
DS00560D-page 20
© 1994 Microchip Technology Inc.
8-118
Note the following details of the code protection feature on PICmicro® MCUs.
•
•
•
•
•
•
The PICmicro family meets the specifications contained in the Microchip Data Sheet.
Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today,
when used in the intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet.
The person doing so may be engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable”.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of
our product.
If you have any further questions about this matter, please contact the local sales office nearest to you.
Information contained in this publication regarding device
applications and the like is intended through suggestion only
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
No representation or warranty is given and no liability is
assumed by Microchip Technology Incorporated with respect
to the accuracy or use of such information, or infringement of
patents or other intellectual property rights arising from such
use or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with
express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, FilterLab,
KEELOQ, microID, MPLAB, PIC, PICmicro, PICMASTER,
PICSTART, PRO MATE, SEEVAL and The Embedded Control
Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, microPort,
Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM,
MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select Mode
and Total Endurance are trademarks of Microchip Technology
Incorporated in the U.S.A.
Serialized Quick Turn Programming (SQTP) is a service mark
of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2002, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received QS-9000 quality system
certification for its worldwide headquarters,
design and wafer fabrication facilities in
Chandler and Tempe, Arizona in July 1999. The
Company’s quality system processes and
procedures are QS-9000 compliant for its
PICmicro® 8-bit MCUs, KEELOQ® code hopping
devices, Serial EEPROMs and microperipheral
products. In addition, Microchip’s quality
system for the design and manufacture of
development systems is ISO 9001 certified.
 2002 Microchip Technology Inc.
M
WORLDWIDE SALES AND SERVICE
AMERICAS
ASIA/PACIFIC
Japan
Corporate Office
Australia
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200 Fax: 480-792-7277
Technical Support: 480-792-7627
Web Address: http://www.microchip.com
Microchip Technology Australia Pty Ltd
Suite 22, 41 Rawson Street
Epping 2121, NSW
Australia
Tel: 61-2-9868-6733 Fax: 61-2-9868-6755
Microchip Technology Japan K.K.
Benex S-1 6F
3-18-20, Shinyokohama
Kohoku-Ku, Yokohama-shi
Kanagawa, 222-0033, Japan
Tel: 81-45-471- 6166 Fax: 81-45-471-6122
Rocky Mountain
China - Beijing
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7966 Fax: 480-792-7456
Microchip Technology Consulting (Shanghai)
Co., Ltd., Beijing Liaison Office
Unit 915
Bei Hai Wan Tai Bldg.
No. 6 Chaoyangmen Beidajie
Beijing, 100027, No. China
Tel: 86-10-85282100 Fax: 86-10-85282104
Atlanta
500 Sugar Mill Road, Suite 200B
Atlanta, GA 30350
Tel: 770-640-0034 Fax: 770-640-0307
Boston
2 Lan Drive, Suite 120
Westford, MA 01886
Tel: 978-692-3848 Fax: 978-692-3821
Chicago
333 Pierce Road, Suite 180
Itasca, IL 60143
Tel: 630-285-0071 Fax: 630-285-0075
Dallas
4570 Westgrove Drive, Suite 160
Addison, TX 75001
Tel: 972-818-7423 Fax: 972-818-2924
Detroit
Tri-Atria Office Building
32255 Northwestern Highway, Suite 190
Farmington Hills, MI 48334
Tel: 248-538-2250 Fax: 248-538-2260
Kokomo
2767 S. Albright Road
Kokomo, Indiana 46902
Tel: 765-864-8360 Fax: 765-864-8387
Los Angeles
18201 Von Karman, Suite 1090
Irvine, CA 92612
Tel: 949-263-1888 Fax: 949-263-1338
China - Chengdu
Microchip Technology Consulting (Shanghai)
Co., Ltd., Chengdu Liaison Office
Rm. 2401, 24th Floor,
Ming Xing Financial Tower
No. 88 TIDU Street
Chengdu 610016, China
Tel: 86-28-6766200 Fax: 86-28-6766599
China - Fuzhou
Microchip Technology Consulting (Shanghai)
Co., Ltd., Fuzhou Liaison Office
Unit 28F, World Trade Plaza
No. 71 Wusi Road
Fuzhou 350001, China
Tel: 86-591-7503506 Fax: 86-591-7503521
China - Shanghai
Microchip Technology Consulting (Shanghai)
Co., Ltd.
Room 701, Bldg. B
Far East International Plaza
No. 317 Xian Xia Road
Shanghai, 200051
Tel: 86-21-6275-5700 Fax: 86-21-6275-5060
China - Shenzhen
150 Motor Parkway, Suite 202
Hauppauge, NY 11788
Tel: 631-273-5305 Fax: 631-273-5335
Microchip Technology Consulting (Shanghai)
Co., Ltd., Shenzhen Liaison Office
Rm. 1315, 13/F, Shenzhen Kerry Centre,
Renminnan Lu
Shenzhen 518001, China
Tel: 86-755-2350361 Fax: 86-755-2366086
San Jose
Hong Kong
Microchip Technology Inc.
2107 North First Street, Suite 590
San Jose, CA 95131
Tel: 408-436-7950 Fax: 408-436-7955
Microchip Technology Hongkong Ltd.
Unit 901-6, Tower 2, Metroplaza
223 Hing Fong Road
Kwai Fong, N.T., Hong Kong
Tel: 852-2401-1200 Fax: 852-2401-3431
New York
Toronto
6285 Northam Drive, Suite 108
Mississauga, Ontario L4V 1X5, Canada
Tel: 905-673-0699 Fax: 905-673-6509
India
Microchip Technology Inc.
India Liaison Office
Divyasree Chambers
1 Floor, Wing A (A3/A4)
No. 11, O’Shaugnessey Road
Bangalore, 560 025, India
Tel: 91-80-2290061 Fax: 91-80-2290062
Korea
Microchip Technology Korea
168-1, Youngbo Bldg. 3 Floor
Samsung-Dong, Kangnam-Ku
Seoul, Korea 135-882
Tel: 82-2-554-7200 Fax: 82-2-558-5934
Singapore
Microchip Technology Singapore Pte Ltd.
200 Middle Road
#07-02 Prime Centre
Singapore, 188980
Tel: 65-334-8870 Fax: 65-334-8850
Taiwan
Microchip Technology Taiwan
11F-3, No. 207
Tung Hua North Road
Taipei, 105, Taiwan
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPE
Denmark
Microchip Technology Nordic ApS
Regus Business Centre
Lautrup hoj 1-3
Ballerup DK-2750 Denmark
Tel: 45 4420 9895 Fax: 45 4420 9910
France
Microchip Technology SARL
Parc d’Activite du Moulin de Massy
43 Rue du Saule Trapu
Batiment A - ler Etage
91300 Massy, France
Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Germany
Microchip Technology GmbH
Gustav-Heinemann Ring 125
D-81739 Munich, Germany
Tel: 49-89-627-144 0 Fax: 49-89-627-144-44
Italy
Microchip Technology SRL
Centro Direzionale Colleoni
Palazzo Taurus 1 V. Le Colleoni 1
20041 Agrate Brianza
Milan, Italy
Tel: 39-039-65791-1 Fax: 39-039-6899883
United Kingdom
Arizona Microchip Technology Ltd.
505 Eskdale Road
Winnersh Triangle
Wokingham
Berkshire, England RG41 5TU
Tel: 44 118 921 5869 Fax: 44-118 921-5820
01/18/02
 2002 Microchip Technology Inc.