PDA

View Full Version : 24lc32 eeprom



Earl Foster
12-31-2005, 08:11 AM
I just received 10 of the 24LC32 EEPROM's for Christmas, along with a bunch of other Parallax electronic goodies, but I don't know how to use them.· I downloaded the data sheet I found in the archieves but I am still confused - I do better by example.· I have looked around and haven't·been able to find·any examples of how to use them in the Stamps in Class series or in Nuts & Volts examples.· Are there any examples available with schemics that show how to use it for external data logging?· If so, can they be posted for downloaded?

cyberbiota
12-31-2005, 08:18 AM
EBF306-

Try this thread in the forum:

http://forums.parallax.com/forums/default.aspx?f=15&m=93373&g=93380#m93380

peter

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Peter C. Charles

Director, Research and Technology
CyberBiota, Incorporated
Peter.charles@cyberbiota.com (mailto:Peter.charles@cyberbiota.com)
http://www.cyberbiota.com (http://www.cyberbiota.com)

cyberbiota
12-31-2005, 08:23 AM
EBF306-

Or, if you are not using a BS-2P, this might be more helpfull:

http://forums.parallax.com/forums/default.aspx?f=5&m=2373&g=2388#m2388

peter

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Peter C. Charles

Director, Research and Technology
CyberBiota, Incorporated
Peter.charles@cyberbiota.com (mailto:Peter.charles@cyberbiota.com)
http://www.cyberbiota.com (http://www.cyberbiota.com)

kogerat
12-31-2005, 08:51 AM
Hi ebf306,

Check out Stampworks 2, expeiment # 32 I2C communications. You can download Stampworks 2 PDF form here:

http://www.parallax.com/dl/docs/books/sw/Web-sw-v2.0.pdf

Hope this helps.

Jim K

Earl Foster
12-31-2005, 11:45 AM
Thank you

Earl Foster
01-03-2006, 03:44 AM
Thanks again for the great info. After downloading all the different materials and reviewing it I decided to do experiment #32 from the StampWorks 2.0 manual. I get to the initialization section and notice the conditional IF statement about using BS2P or higher. It tells me to use another code SW20-EX32-24LC32-BSP. So now I am stumped.

First, I thought the I2C commands were only available for BS2P and above?
And secondly, is SW20-EX32-24LC32-BSP available for download?

Jon Williams
01-03-2006, 04:24 AM
Native I2C commands are indeed built into the BS2p family, but as that experiment shows you can do I2C on any BS2 module with a bit of code.· And yes, all of the programs are available for download from the product page.

http://www.parallax.com/detail.asp?product_id=27297

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

kogerat
01-03-2006, 04:52 AM
Hi ebf306,

I assumed you had a BS2. You can do I2C communications with a BS2, but it takes more code than BS2p that has I2C instructions. You can download the source code for the Stampworks 2 experiments·SW20-EX32-24LC32.BS2 and SW20-EX32-24LC32.BSP along with all of the Stampworks 2 source code from here http://www.parallax.com/detail.asp?product_id=27297·at the bottom of the page.

Sorry for the confusion

Jim K

PS, I see Jon beat me to it. Thanks Jon for following up on my less than concise posts!!

Earl Foster
01-20-2006, 05:37 PM
I have been studing and breaking apart the sample programs but I think I am still confused.· So to help me get straight I wrote my own versions and one works and one doesn't.· The first version writes and reads before incrementing the address by 2 bytes.· And the reason why I am jumping 2 bytes is because I have declared the "x" and "y" values to be words which is also the reason why I am using wrdAddr.BYTE1\wrdAddr.BYTE0 directive.

************************************************** *******
' {$STAMP BS2p}
' {$PBASIC 2.5}
SCL············PIN···· 1··············' I2C serial clock line
wrdAddr······VAR···· Word········' word address
X·············· VAR···· Word········' General purpose variable
y·············· VAR···· Word······· ' General purpose variable
wrdAddr = 0·························' Initialize address location
x = 100
DO
·· I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 x]
·· DEBUG HOME
·· DEBUG ? x
·· DEBUG ? wrdAddr
·· I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 y]
·· DEBUG ? y
·· wrdAddr = wrdAddr + 2
·· x = x + 100
·· PAUSE 1000
LOOP UNTIL wrdAddr = 20
************************************************** *********
This next one writes properly but reads junk back and I don't understand why.
************************************************** *********
' {$STAMP BS2p}
' {$PBASIC 2.5}
SCL············PIN···· 1··············' I2C serial clock line
wrdAddr······VAR···· Word········' word address
X·············· VAR···· Word········' General purpose variable
y·············· VAR···· Word······· ' General purpose variable
wrdAddr = 0
x = 100
DO······················· ' Works
·· I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 x]
·· DEBUG HOME
·· DEBUG ? x
·· DEBUG ? wrdAddr
·· wrdAddr = wrdAddr + 2
·· x = x + 100
·· PAUSE 1000
LOOP UNTIL wrdAddr = 20
wrdAddr = 0
DEBUG CLS
DO······················ 'Doesn't work
·· I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 y]
·· DEBUG HOME
·· DEBUG ? y
·· DEBUG ? wrdAddr
·· wrdAddr = wrdAddr + 2
·· PAUSE 1000
LOOP UNTIL wrdAddr = 20
************************************************** *********

Can someone straighten me out and tell·what I am doing wrong?

Earl Foster
01-21-2006, 09:50 AM
ok I think I have a better understanding of the 24LC32. It only accepts Bytes. So my question is if I need to record a WORD would I run the I2COUT command twice to capture the data?

I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 x.byte1]
I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 x.byte0]

or could I do

I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [DEC5 x.BYTE1, DEC5 x.BYTE0]

Jon Williams
01-21-2006, 03:12 PM
No, when you use the DEC5 modifier you are sending five bytes. This is one way to store a word-sized variable in the 24LC32, but it's ineffecient as it uses three bytes more than are actually required. Write two bytes: myWord.BYTE0, then myWord.BYTE1. Make sure you read the back in the same order.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Earl Foster
01-21-2006, 11:28 PM
Thanks Jon. I still don’t understand something that is happening when I go to read the data out of memory. In the first part of my code I am inserting a value of x and displaying the value and memory location on the screen.

DO
I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [x.BYTE0, x.BYTE1]
DEBUG ? x 'show me the value I am storing
DEBUG ? wrdAddr 'show me the address location
x = x + 200 'increment the value of x
wrdAddr = wrdAddr + 1 'increment to next memory location
PAUSE 1000 'slow down the read out
LOOP UNTIL wrdAddr = 5

This seems to be working properly but when I go to read the values starting at location 0 using this code:

wrdAddr = $0 'Go back to address 0
DO
I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [x.BYTE0, x.BYTE1]
DEBUG ? x 'show me the value in memory
DEBUG ? wrdAddr 'show me the address location
wrdAddr = wrdAddr + 1 'increment to next memory location
PAUSE 1000 'slow down the read out
LOOP UNTIL wrdAddr = 5

I get completely different values back (37064, 22672, 8280, 59424, 1000). Apparently I am still missing something in my understanding on how to write and read to memory.

Jon Williams
01-21-2006, 11:34 PM
The problem is with your incrementing of wrdAddr -- you need to make it

· wrdAddr = wrdAddr + 2

... as you are writing/reading two bytes. In your current program each write to the EE is clobbering the previous value.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Earl Foster
01-22-2006, 12:24 AM
Thanks Jon. :) Its so obvious once you see it - duh!!

Jon Williams
01-22-2006, 03:28 AM
Yes, we all have those "smack to the forehead" moments from time-to-time.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax