EEPROM Interface?
Archiver
Posts: 46,084
Hello!
I'm having some trouble with an interface to a Fairchild FM93C86A EEPROM. Here
is the program I'm using:
'{$STAMP BS2sx}
MemLoc var Word
Received var Word
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%10011111111] ' initialize EEPROM, write enable
Low 5
For MemLoc = 0 to 2047
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%101, MemLoc\11, %10101010] ' write %10101010 to
EEPROM
Low 5
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%110, MemLoc\11] ' Read EEPROM
Shiftin 7, 0, MSBPOST, [noparse][[/noparse]Recieved\16] ' Receive
data from EEPROM
Low 5
Debug BIN Received, CR '
Display received data
Received = 0
next
This is simply a test program I wrote to test the EEPROM, and begin software
development for it. The Stamp returns %1111111111111111 with the DEBUG. Do any
of you Stampers see anything amiss? I'm using the EEPROM with the 8 bit memory
organization. P0 is the clock pin, P6 is DO, P7 is DI. I've checked all the
connections, and everything looks OK, hardware-wise. Has anyone had any
experience with this EEPROM (I've attached the data sheet)? If not, am I doing
anything else wrong (under the influence of too many caffeinated sodas and the
toothpicks to keep the eyelids open late at night)? Eventually, I'm going to use
the EEPROM in an airspeed/altimetry data logging function for a sailplane as
part of my 11th grade science fair project.
Thanks a lot for your help!
Robert
[noparse][[/noparse]Non-text portions of this message have been removed]
I'm having some trouble with an interface to a Fairchild FM93C86A EEPROM. Here
is the program I'm using:
'{$STAMP BS2sx}
MemLoc var Word
Received var Word
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%10011111111] ' initialize EEPROM, write enable
Low 5
For MemLoc = 0 to 2047
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%101, MemLoc\11, %10101010] ' write %10101010 to
EEPROM
Low 5
High 5
Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%110, MemLoc\11] ' Read EEPROM
Shiftin 7, 0, MSBPOST, [noparse][[/noparse]Recieved\16] ' Receive
data from EEPROM
Low 5
Debug BIN Received, CR '
Display received data
Received = 0
next
This is simply a test program I wrote to test the EEPROM, and begin software
development for it. The Stamp returns %1111111111111111 with the DEBUG. Do any
of you Stampers see anything amiss? I'm using the EEPROM with the 8 bit memory
organization. P0 is the clock pin, P6 is DO, P7 is DI. I've checked all the
connections, and everything looks OK, hardware-wise. Has anyone had any
experience with this EEPROM (I've attached the data sheet)? If not, am I doing
anything else wrong (under the influence of too many caffeinated sodas and the
toothpicks to keep the eyelids open late at night)? Eventually, I'm going to use
the EEPROM in an airspeed/altimetry data logging function for a sailplane as
part of my 11th grade science fair project.
Thanks a lot for your help!
Robert
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
After a look at the spec sheet I found two issues:
1) I think your write enable sequence is not correct. The spec says
1 00 11 XXXXXXXXX, total of 14 bits
1 00 11 111111 - you send only 11 bits
2) When reading the data into 'Received' you are reading 16 bits.
After the spec (as you are using 8bit organisation) you should expect
0, D7 - D0 (the 0 is the dummy bit) which is a total of 9 bits.
(Probably you can just read your 9 bits of data into a byte variable
and get rid of the dummy 0 bit, but I would first try with a word
variable)
Hope this helps
Regards
>I'm having some trouble with an interface to a Fairchild FM93C86A
>EEPROM. Here is the program I'm using:
>
>'{$STAMP BS2sx}
>
>MemLoc var Word
>Received var Word
>
>High 5
>Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%10011111111] ' initialize EEPROM, write enable
>Low 5
I think you need to send 14 bits instead of 11 bits, that is, the
start bit, the two command bits, and the whole 11 bit address field.
The shiftout command defaults to 8 bits, so you need the \14 to tell
it to send more. Like this... [noparse][[/noparse]%10011111111111\14]
>
>For MemLoc = 0 to 2047
>High 5
>Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%101, MemLoc\11, %10101010] ' write
>%10101010 to EEPROM
>Low 5
The group of 3 bits needs a \3: [noparse][[/noparse]%101\3, MemLoc\11, %10101010\8]
The %10101010 does not really need the \8, because that is the default
>
>High 5
>Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%110, MemLoc\11] ' Read EEPROM
>Shiftin 7, 0, MSBPOST, [noparse][[/noparse]Recieved\16]
>' Receive data from EEPROM
>Low 5
Again, the group of 3 needs to be specified [noparse][[/noparse]%110\3, MemLoc\11].
With 8 bit organization (ORG pin tied low), you only need to shift in
9 bits. 9 because the first bit out is a dummy zero, followed by 8
significant bits. [noparse][[/noparse]Received\9]
"cei"
>
>Debug BIN Received, CR
>' Display received data
>
>Received = 0
>next
>
>This is simply a test program I wrote to test the EEPROM, and begin
>software development for it. The Stamp returns %1111111111111111
>with the DEBUG. Do any of you Stampers see anything amiss? I'm using
>the EEPROM with the 8 bit memory organization. P0 is the clock pin,
>P6 is DO, P7 is DI.
Remember that the Stamp has to SHIFTOUT to the eeprom's DI pin, and
SHIFTIN from the eeprom's DO pin. IS that what you have?!
> I've checked all the connections, and everything looks OK,
>hardware-wise. Has anyone had any experience with this EEPROM (I've
>attached the data sheet)? If not, am I doing anything else wrong
>(under the influence of too many caffeinated sodas and the
>toothpicks to keep the eyelids open late at night)? Eventually, I'm
>going to use the EEPROM in an airspeed/altimetry data logging
>function for a sailplane as part of my 11th grade science fair
>project.
>Thanks a lot for your help!
>
>Robert
Good luck with your project!
-- regards,
Tracy Allen
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com
I just started reading this list server and don't yet have a BS, but am
programming PICs.
When writing to a EEPROM the timing is very important. It typically takes some
milliseconds to write data although you can read it just like RAM.
Have Fun,
Brooke Clarke, N6GCE
http://www.prc68.com
> Date: Mon, 6 Jan 2003 22:18:22 -0700
> From: "Robert Ussery" <uavscience@f...>
> Subject: EEPROM Interface?
>
> Hello!
> I'm having some trouble with an interface to a Fairchild FM93C86A EEPROM. Here
is the program I'm using:
>
> '{$STAMP BS2sx}
>
> MemLoc var Word
> Received var Word
>
> High 5
> Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%10011111111] ' initialize EEPROM, write enable
> Low 5
>
> For MemLoc = 0 to 2047
> High 5
> Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%101, MemLoc\11, %10101010] ' write %10101010 to
EEPROM
> Low 5
>
> High 5
> Shiftout 6, 0, MSBFIRST, [noparse][[/noparse]%110, MemLoc\11] ' Read EEPROM
> Shiftin 7, 0, MSBPOST, [noparse][[/noparse]Recieved\16] ' Receive
data from EEPROM
> Low 5
>
> Debug BIN Received, CR '
Display received data
>
> Received = 0
> next
>
> This is simply a test program I wrote to test the EEPROM, and begin software
development for it. The Stamp returns %1111111111111111 with the DEBUG. Do any
of you Stampers see anything amiss? I'm using the EEPROM with the 8 bit memory
organization. P0 is the clock pin, P6 is DO, P7 is DI. I've checked all the
connections, and everything looks OK, hardware-wise. Has anyone had any
experience with this EEPROM (I've attached the data sheet)? If not, am I doing
anything else wrong (under the influence of too many caffeinated sodas and the
toothpicks to keep the eyelids open late at night)? Eventually, I'm going to use
the EEPROM in an airspeed/altimetry data logging function for a sailplane as
part of my 11th grade science fair project.
> Thanks a lot for your help!
>
> Robert
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 21
> Date: Mon, 6 Jan 2003 22:27:43 -0700
> From: "Robert Ussery" <uavscience@f...>
> Subject: EEPROM Interface...
>
> Sorry about that...
> I forgot that the Stamp group doesn't support attachments. Here's the data
sheet for the EEPROM I used:
> http://www.fairchildsemi.com/ds/FM/FM93C86A.pdf
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 22
> Date: Tue, 07 Jan 2003 08:15:45 -0000
> From: "Adrian Schneider <adrian.schneider@t...>"
<adrian.schneider@t...>
> Subject: Re: EEPROM Interface?
>
> Hi
> After a look at the spec sheet I found two issues:
>
> 1) I think your write enable sequence is not correct. The spec says
> 1 00 11 XXXXXXXXX, total of 14 bits
> 1 00 11 111111 - you send only 11 bits
>
> 2) When reading the data into 'Received' you are reading 16 bits.
> After the spec (as you are using 8bit organisation) you should expect
> 0, D7 - D0 (the 0 is the dummy bit) which is a total of 9 bits.
> (Probably you can just read your 9 bits of data into a byte variable
> and get rid of the dummy 0 bit, but I would first try with a word
> variable)
>
> Hope this helps
> Regards
I had forgotten that it was necessary to SHIFTOUT a full 14 bits, even
though only a couple of them are used. As far as having the wrong pins for
DO, DI, I think that was simply a case of writing the email without looking
at the circuit. I did, in fact have the pins set up correctly for the
program. I was shifting in 16 bits on purpose just to make sure I got the
data, even if I had set something up wrong, and to verify that I had
correctly tied down the ORG pin.
I think this was another case of burning the midnight oil, and burning
myself [noparse]:)[/noparse]
Thanks again for your help!
Robert
2 weeks on and I'm no further than on the second night of trying!
I think I'm reading my eeprom OK. I have a 93C46N that came out of an
old PCB so has some data in it already I think. Thats what this
program seems to show me anyway. I'm using it in 8 bit mode with the
ORG pin tied low.
My problem is that I cant write to the device. I've read the data
sheets so many times I can recite them backwards. Obviously I've
missed something. I'd be very grateful if someone could point out
what!
CS con 11
SK con 10
DI con 9
DO con 8
Memloc VAR byte
received VAR byte
LOOP: for Memloc = 0 to 35
high CS ' select chip
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%110, Memloc\7] '110=start bit,read
command +7 addr bits
SHIFTIN DO,SK,MSBPOST, [noparse][[/noparse]received\9] '9=1 dummy bit +8 data
LOW CS
DEBUG DEC Memloc," ", DEC received," ",asc ? received
Next
'now lets write enable
high cs
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%1001100000] 'WEN write enable
low cs '10011=WEN command, other bits dont care.
pause 1 'just in case its needed
'now lets write to memory adress 2
high cs
Memloc = 2 'set memory address to 2
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%101, Memloc\7,5] ' 101=write
command. Put 5 into Memloc
low cs
pause 20 '>15mS pause required according to data sheet
'now lets write disable
high cs
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%1000000000] 'WDS write disable
low cs '10000=WDS command, other bits dont care
' now lets see if location 2 has changed value!
LOOP2:
for Memloc = 0 to 35
high CS ' select chip
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%110, Memloc\7] '110=start bit+read
command +7 address bits
SHIFTIN DO,SK,MSBPOST, [noparse][[/noparse]received\9] '9=1 dummy bit plus 8
data
LOW CS
DEBUG DEC memloc," ", DEC received," ",asc ? received
Next
stop 'Damn! No change.
Dominic
ex G0DOM!
- In basicstamps@yahoogroups.com, Brooke Clarke <brooke@p...> wrote:
> Hi Robert:
>
> I just started reading this list server and don't yet have a BS,
but am programming PICs.
> When writing to a EEPROM the timing is very important. It
typically takes some milliseconds to write data although you can read
it just like RAM.
>
> Have Fun,
>
> Brooke Clarke, N6GCE
> http://www.prc68.com
>
>
After a glance into your code I see a lot of shiftout where you use
data of size different from 8 bit. As far as I know shiftout allways
shifts in quantities of 8 bit unless specified otherwise.
Have you tried applying the correct size modifiers everywhere where
you want to shift a number of bits different from 8 bits (larger AND
lower quantities), e.g.
[noparse][[/noparse]%110\3, Memloc\7] instead of just [noparse][[/noparse]%110, Memloc\7] and so on
BTW do you have a digital storage osciloscope at your disposal - it
might be useful here?
Hope this helps
Adrian
I've been mucking about with a 93C46 chip for the last couple of
weeks. I had a chip lying around to try, unfortunately the chip I
have will only allow access in 16 bit memory mode. That really caught
me out! Therefore my program is more complicated than necessary if I
could address in 8 bit mode. Also remember there will be some changes
to get it to operate a 93C86 chip because of its greater address
range. Also you have to make sure that you access the Memloc that you
really want. If you just shift out the 6 most significant bits of an
8 bit counter, the chip will not see the value you intended to send.
To get around that I shifted the location pointer 2 bits to the left
before shiftout. See listing......
The program below will first show whats in the eprom then poke a test
16 bit value VAL into each memory location then show the new
contents. Its not very practical at the moment but I'm sure you will
see how I accessed the device.
CS con 11
SK con 10
DI con 9
DO con 8
x VAR byte
Memloc VAR byte
VAL VAR word
received VAR word
HIGHB VAR received.HIGHBYTE
LOWB VAR received.LOWBYTE
'I spent AGES trying to program in 8 bit mode a version of the chip
that would only operate in 16 bit mode. BEWARE!
'First lets see inside.
for x = 0 to 63
memloc = x<<2 'shift x left
2 bits so that the correct address is shitfed into the chip.
high CS ' select chip
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%110\3, Memloc\6] ' "110"=start
bit,read command +6 addr bits
SHIFTIN DO,SK,MSBPRE, [noparse][[/noparse]received\1,received\16] '1 dummy bit
plus 16 data bits
LOW CS 'deselect chip
DEBUG "memloc=",BIN8 memloc," ",DEC3 x," ",HEX4
received," ",HIGHB," ",LOWB,CR
Next
'now lets write enable
high cs
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%100110000\9] 'WEN command write
enable
low cs '10011=WEN command,
other 6 bits dont care.
VAL=$2010 'test value to be poked into memory
'now lets write 16 bits to memloc
for x= 0 to 63
Memloc =x<<2
high cs
SHIFTOUT DI,SK,MSBFIRST,[noparse][[/noparse]%101\3,Memloc\6,val\16] ' 101=write
command.Put val into Memloc
pause 20 '>15mS pause
required according to data sheet
low cs
DEBUG DEC3 X," ",BIN8 MEMLOC,CR
next
stop
'now lets write disable
high cs
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%100000000\9] 'WDS command write
disable
low cs '10000=WDS command,
other bits dont care
'now lets see if locations have changed value!
for x = 0 to 63
Memloc=x<<2
high CS ' select chip
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%110\3, Memloc\6] '110=start
bit+read command +7 address bits
SHIFTIN DO,SK,MSBPRE, [noparse][[/noparse]received\1,received\16] '9=1 dummy
bit plus 8 data
LOW CS
DEBUG DEC3 memloc," ",DEC3 x," ",HEX4
received," ",HIGHB," ",LOWB,CR
Next
Dominic
--- In basicstamps@yahoogroups.com, "Adrian Schneider
<adrian.schneider@t...>" <adrian.schneider@t...> wrote:
> Hi, I remember your issue.
> After a glance into your code I see a lot of shiftout where you use
> data of size different from 8 bit. As far as I know shiftout allways
> shifts in quantities of 8 bit unless specified otherwise.
> Have you tried applying the correct size modifiers everywhere where
> you want to shift a number of bits different from 8 bits (larger
AND
> lower quantities), e.g.
>
> [noparse][[/noparse]%110\3, Memloc\7] instead of just [noparse][[/noparse]%110, Memloc\7] and so on
>
> BTW do you have a digital storage osciloscope at your disposal - it
> might be useful here?
>
> Hope this helps
> Adrian
93CXX with minimal modification because I used them to read the
contents of the password eeprom in my Thinkpad laptop.
I hope you find them useful.
Dominic
'{$STAMP BS2}
'{$PBASIC 2.0}
CS con 11 'chip select
SK con 10 'serial clock
DI con 9 'data in
DO con 8 'data out
memloc VAR byte
VAL VAR word
received VAR word
HIGHB VAR received.HIGHBYTE
LOWB VAR received.LOWBYTE
start: pause 1000
low sk
for memloc=0 to 63
gosub rd
SEROUT 13, $4054, [noparse][[/noparse]lowb ]
SEROUT 13, $4054, [noparse][[/noparse]highb ]
next
stop
PRINT: DEBUG "val=",DEC5 val," ","mem=",DEC3 MEMLOC," ","rec=",HEX4
received," ",LOWB,HIGHB,CR
return
RD: 'Read 16 bits from memloc. Values of memloc between 0 and 63
valid
high CS
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%110\3,memloc\6] ' %
110=start bit,read command +6 addr bits
SHIFTIN DO,SK,MSBpre, [noparse][[/noparse]received\1,received\16] '1 dummy bit
plus 16 data bits
LOW CS
return
WR: high cs 'write 16 bits to memloc. Values of memloc between
0 and 63 valid
SHIFTOUT DI,SK,MSBFIRST,[noparse][[/noparse]%101\3,memloc\6,val\16] ' %101=write
command
low cs '>15mS pause required
according to data sheet
pause 50 'min time starts from after CS is pulled low!
Earlier progs the pause was before the CS!
return
WEN: high cs 'write enable
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%100110000\9] 'WEN command write
enable
low cs '10011=WEN command,
other 6 bits dont care.
return
WDS: high cs 'write disable
SHIFTOUT DI,SK, MSBFIRST,[noparse][[/noparse]%100000000\9] 'WDS command write
disable
low cs '10000=WDS command,
other bits dont care
return