Shop OBEX P1 Docs P2 Docs Learn Events
help with eeproms... — Parallax Forums

help with eeproms...

ArchiverArchiver Posts: 46,084
edited 2003-03-12 20:01 in General Discussion
Hi, i'm relatively new to basic stamps, and totally new to eeproms... I have
an eeprom that I just bought, the AT24CO2.

It's a serial eeprom, 2-wire, 8 pins, 2k. Can anyone help me with
programming/reading? Can I use the program posted earlier for the 93CXX?
I'm posting the program below for reference....
Thanks!
Giacomo

'{$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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 01:21
    That's an I2C device. You can get I2C routines for the BS2 from many sources
    on the Internet, including my "Nuts & Volts" article "I2C Fun For Everyone."
    You can download a PDF of the article from the Parallax web site.

    -- Jon Williams
    -- Parallax


    In a message dated 3/11/2003 6:04:25 PM Central Standard Time,
    progman32@c... writes:

    > Hi, i'm relatively new to basic stamps, and totally new to eeproms... I have
    > an eeprom that I just bought, the AT24CO2.
    >
    > It's a serial eeprom, 2-wire, 8 pins, 2k. Can anyone help me with
    > programming/reading? Can I use the program posted earlier for the 93CXX?
    > I'm posting the program below for reference....
    > Thanks!
    > Giacomo
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 20:01
    Ok, thanks! I'll check it out!
    Giacomo
    ________________________________________________________________________
    ________________________________________________________________________


    Date: Tue, 11 Mar 2003 20:21:51 EST
    From: jonwms@a...
    Subject: Re: help with eeproms...

    That's an I2C device. You can get I2C routines for the BS2 from many
    sources
    on the Internet, including my "Nuts & Volts" article "I2C Fun For Everyone."
    You can download a PDF of the article from the Parallax web site.

    -- Jon Williams
    -- Parallax


    In a message dated 3/11/2003 6:04:25 PM Central Standard Time,
    progman32@c... writes:

    > Hi, i'm relatively new to basic stamps, and totally new to eeproms... I
    have
    > an eeprom that I just bought, the AT24CO2.
    >
    > It's a serial eeprom, 2-wire, 8 pins, 2k. Can anyone help me with
    > programming/reading? Can I use the program posted earlier for the 93CXX?
    > I'm posting the program below for reference....
    > Thanks!
    > Giacomo
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]



    ________________________________________________________________________
Sign In or Register to comment.