PDA

View Full Version : 16f84a + 24lc16b Eeprom



exelanoz
- 26th February 2006, 04:44
Hello there!

I am using a 16F84A @ 4Mhz XT with a 24LC16B, 4.7K Res. on SDA, SCL.
All A0 A1 A2 to GND, WP is on GND

My aim is to write Variable Bytes into the 24LC16B and then have the ability to retrieve them from random locations within the EEPROM.

Being a beginner with EEPROMS, I have used the examples given by Les Johnson 'Experimenting with PICBasicPro' then I have modified the code, but with little results. If anyone has any tips or pointers, it would be much appreciated.

I have read and re-read and studied the wretched data sheets for the 24LC16B, the diagrams showing it requires these to Write: 'Control Byte' + 'Word Address' + 'Data'

That all makes sense, however when I change the 'Word Address' to 'Byte Address', it starts working with the first 10 locations on the eeprom and any subsequent writes from 11 and on are not OK neither can I read them back correctly... or am I just illiterate with the data sheets????

I can read back "Hello World" only.

I've attached the TXT file with the Code.

I understand that to do random read it has to do a 'Control Byte' Write and then do a 'Control Byte' Read, this is so the internal address pointer is in the right direction, - but using the i2c commands, is this feasible?
Would you do a i2cwrite with a blank variable then switch to a i2cread??

If anything is unclear, let me know, so I can try and explain it better.
Cheers

From the Land down under

AP

exelanoz
- 28th February 2006, 10:18
Well after much experimentation (putting a ZIF socket thru its paces)
**my programmer and hobby testbed are two different things. I endavour to put a programmer connection on my testbed eventually, when my little spare time allows**
i tried a 24lc256, and yes it does use a word address. Works well, or at least it appears that way.

But leaving the code 'as is' leaves the last character of line 1 in the variable E_Byteout, and it displays this last character in the second line address range.

So...I put together the whole thing in one line and write it (address = 0 to 18), then next read out the text on two seperate lines.(address = 0 to 10 and 11 to 18)

My 2 questions are:
Why can't I put 2x "Lookup" one after the other like I have in the example.
Why won't the EEPROM record anything if I use the FOR and NEXT command to insert the address word say from 18 to 36?

Many thanks

AP

**Oh one last thing. Sentence in the first section needs clarifying. My aim is not to write variable bytes into the EEPROM...instead i should be going along the lines of 'wanting to write character strings into it and then retrieving them from alternate locations' :-)

exelanoz
- 1st March 2006, 05:09
Hehe Super Duper! It's Working!

Finally i've got it all worked out.
As they say "more than one way to skin a cat", - sorry, I mean no offence to any animal lovers. (I love my beautiful pet fishes)

I had problem writing to different memory locations on a 24LC16.

Like write:

"Fish" to 0 to 3 (locations)

after that put

"plant" to 20 to 25 (locations)

All good now. It was a simple fix.

AP


I would love to see some replies to any future posts...over 50 views and no reponse? What little I know is self taught, so expect to see some ridiculous code from me:-) and don't laugh.