93LC56B/P Serial EEPROM
Tommi
Posts: 3
I try write/read data to 93LC56B/P chip. It is 128x16 bit organization EEPROM with 3-wire serial interface.
Eveything shows good until I press BOEs reset. Then reread chip and some data are changed.
Can anyone help?
Thanks, Tommi
My test program:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'
' BOE Rev B, BS2SX v1.0, 93LC56B/P EEPROM 128x16
'
' CS (1) --> P11 CLK (2) --> P12
' Din (3) --> P13 Dout (4) --> P14
' Vss (5) --> Vss NC (6)
' NC (7) Vcc (8) --> Vdd
CS CON 11
CLK CON 12
Din CON 13
Dout CON 14
Pse CON 5 'Delay for pauses
TstDta CON $1111 'Test data, easy chance
Addr VAR Byte
Dta VAR Word
DtaHi VAR Dta.HIGHBYTE
DtaLo VAR Dta.LOWBYTE
Tmp VAR Bit
main:
DEBUG CLS
Addr = $00 'Read data from specified address $00
GOSUB RdRom
IF Dta <> TstDta THEN
DEBUG "Data from address $00: ", HEX4 Dta,CR
DEBUG "Write ",HEX4 TstDta, " into all address $00-$7F",CR
GOSUB EwenRom 'Enable Erase/Write EWEN
FOR Addr = $00 TO $7F
Dta = TstDta
GOSUB WrtRom 'Write data into specified address
NEXT
GOSUB EwdsRom 'Disable Erase/Write EWDS
ENDIF
FOR Addr = $00 TO $7F
GOSUB RdRom 'Read data from specified address
DEBUG HEX2 Addr," ", HEX4 Dta,CR
NEXT
END
EwenRom: 'Erase/Write Enable EWEN
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%10011\5, 0\6]
LOW CS
PAUSE Pse
RETURN
EwdsRom: 'Erase/Write Disable EWDS
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%10000\5, 0\6]
LOW CS
PAUSE Pse
RETURN
WrtRom: 'Write data into specified address
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%101\3, Addr, DtaHi, DtaLo]
LOW CS
PAUSE Pse
RETURN
'Read data into specified address
RdRom:
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%110\3, Addr]
SHIFTIN Dout, CLK, MSBPRE, [noparse][[/noparse]Tmp\1, DtaHi, DtaLo]
LOW CS
PAUSE Pse
RETURN
Eveything shows good until I press BOEs reset. Then reread chip and some data are changed.
Can anyone help?
Thanks, Tommi
My test program:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'
' BOE Rev B, BS2SX v1.0, 93LC56B/P EEPROM 128x16
'
' CS (1) --> P11 CLK (2) --> P12
' Din (3) --> P13 Dout (4) --> P14
' Vss (5) --> Vss NC (6)
' NC (7) Vcc (8) --> Vdd
CS CON 11
CLK CON 12
Din CON 13
Dout CON 14
Pse CON 5 'Delay for pauses
TstDta CON $1111 'Test data, easy chance
Addr VAR Byte
Dta VAR Word
DtaHi VAR Dta.HIGHBYTE
DtaLo VAR Dta.LOWBYTE
Tmp VAR Bit
main:
DEBUG CLS
Addr = $00 'Read data from specified address $00
GOSUB RdRom
IF Dta <> TstDta THEN
DEBUG "Data from address $00: ", HEX4 Dta,CR
DEBUG "Write ",HEX4 TstDta, " into all address $00-$7F",CR
GOSUB EwenRom 'Enable Erase/Write EWEN
FOR Addr = $00 TO $7F
Dta = TstDta
GOSUB WrtRom 'Write data into specified address
NEXT
GOSUB EwdsRom 'Disable Erase/Write EWDS
ENDIF
FOR Addr = $00 TO $7F
GOSUB RdRom 'Read data from specified address
DEBUG HEX2 Addr," ", HEX4 Dta,CR
NEXT
END
EwenRom: 'Erase/Write Enable EWEN
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%10011\5, 0\6]
LOW CS
PAUSE Pse
RETURN
EwdsRom: 'Erase/Write Disable EWDS
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%10000\5, 0\6]
LOW CS
PAUSE Pse
RETURN
WrtRom: 'Write data into specified address
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%101\3, Addr, DtaHi, DtaLo]
LOW CS
PAUSE Pse
RETURN
'Read data into specified address
RdRom:
HIGH CS
PAUSE Pse
SHIFTOUT Din, CLK, MSBFIRST, [noparse][[/noparse]%110\3, Addr]
SHIFTIN Dout, CLK, MSBPRE, [noparse][[/noparse]Tmp\1, DtaHi, DtaLo]
LOW CS
PAUSE Pse
RETURN