EEPROM Operation

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

EEPROM Operation

Post by 1Handypal »

Hello all!
I am trying to get a simple code working which reads values from chip's built-in EEPROM. When I manually enter EEPROM values into each location shown on panel, simulation works fine. But resulting compiled hex does not contain any EEPROM data or else I am doing it all wrong. Could anybody share their experience with this kind of setup?
Thanks in advance.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: EEPROM OPERATION

Post by JohnCrow »

Hi
Can you post your flowchart so we can see how you are trying to store values in the eeprom
1 in 10 people understand binary, the other one doesn't !

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM OPERATION

Post by Enamul »

Hello

Here is an example code for EEPROM using FCV4 so can be used in FCV5..
Attachments
EEPROM.fcf
(6 KiB) Downloaded 692 times
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: EEPROM OPERATION

Post by Steve001 »

is this what you want to do ?

http://www.matrixmultimedia.com/mmforum ... =29&t=7887

steve
Success always occurs in private and failure in full view.

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: EEPROM OPERATION

Post by 1Handypal »

Hello guys, Steve in particular.
Thanks for the tips! It is most useful help to see the examples. I still have more questions coming into mind. Since EEPROM definitely can be used and preloaded with user data, is it easier to use external I2C connected EEPROM chip? Will the compiled hex contain data to be loaded into the chip's built-in EEPROM? I do not call any EEPROM write function, just reading from, and my chip does not support it anyways. But, say, I wanted to add a function within my flowchart to permanently modify and store data in the EEPROM, can it be done with: 1.the chip that supports it from within or 2.Simply by using external I2C EEPROM?
Thanks for your help! It is greatly appreciated. I am hoping to become registered user of FLowcode 5 soon, for now just practicing underground...

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: EEPROM OPERATION

Post by Steve001 »

Just one thing it is recomended that you don't use Loc 0 within the eprom this comes from microchip

Attached is a example circuit from a modbus project that uses a serial eprom, i haven't yet had chance to dabble with it yet
I have used the internal eprom within a pic quite successfully

http://english.modbus.pl/node/18

steve
Attachments
pic_circuit.jpg
pic_circuit.jpg (46.28 KiB) Viewed 17768 times
Success always occurs in private and failure in full view.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

PLEASE LET ME KNOW OF AN IDEA HOW TO USE I2C IN FLOWCODE FOR READING AND WRITING TO A SERIAL EEPROM FOR EXAMPLE 24C02.....

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM Operation

Post by Enamul »

Have you tried this example? I have used that and it works fine for me.
Attachments
3. EEPROM read and write.fcf
(11.74 KiB) Downloaded 571 times
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

hi enamul thanks for updating schematic and other info. I have tried your sample code but it's continuously printing & reading back "255"

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

Aint working for me, ACK returns 1,1,1,1 read operation returns 255.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

any suggestions?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEPROM Operation

Post by medelec35 »

Hi greentech,
I have just modified Flowchart to simplify reading and writing to 24LC512.
Confirmed working on my hardware.
Make sure A0,A1 and A2 are all connected to ground.

I have modified flowchart so its easy to change change the address (you will need to change A0 to A3 so it matches address)

Hope this helps

Martin
Attachments
EEPROM read and write V2 .fcf
(15.5 KiB) Downloaded 388 times
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

Thanks Martin,

Ill have to order this chip, ill update u soon regarding this.

Kind Regards,

Fairy.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEPROM Operation

Post by medelec35 »

No probs.
What chip have you got?

I thought you had the one I tested, thats why I posted about it.
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

martin i was working with 24C04

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEPROM Operation

Post by medelec35 »

Hi greentech,
I'm not that good with I2C yet, so I won't know all the answers, and can easily get it wrong.

But have you tried using Flowchart I posted with say two 4k7 resistors.
One connected between SCL and +5V the other connected between SDA and 5V.
A0, A1 and A2 all connected to 0V
The address both 24LC512 and 24C04use (leaving out A0 - A3 for now) looks the same at 1010
So it may just work with 24C04 for you?
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

this program doesnt work at all. each time i load it it returns same 255 value. what value are u getting?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EEPROM Operation

Post by kersing »

Could you post a diagram showing the way you connected your hardware and the flow code file you are using?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

hi there, here is the diagram and the code i am using is the same as posted by Enamul » Thu Jun 27, 2013 10:23 am
Attachments
3. EEPROM read and write.fcf
(19.04 KiB) Downloaded 286 times
eeprom.jpg
eeprom.jpg (141.6 KiB) Viewed 16737 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEPROM Operation

Post by medelec35 »

Hi greentech,
I know code I posted (EEPROM read and write V2 .fcf) worked on hardware.

If it does not work on your simulator then that could be suspect.
Simulators are very good, but it must be realise they are not perfect.

Time permitting, I will double check and compare hardware V simulator when I get to work.

Martin
Martin

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EEPROM Operation

Post by kersing »

Hi greentech,

The macros you are using are Receive/Send_Byte_Transaction. These macros send:
1) Device ID
2) AddrH
3) AddrL
4) Data (for Send, read data for Receive)

The device expects (according to its data sheet):
1) Slave address
2) Address byte
3) Data byte.

So the sequences do not match. You should program the sequences yourself using Transmit_Byte and Receive_Byte. Sequence for receive would be:

Code: Select all

MI2C_Start                                        // Start I2C transaction
Mi2C_Transmit_Byte(0b10100000)                    // Address device
MI2C_Transmit_Byte(address byte)                  // Select address to read
MI2C_Restart                                      // Restart transaction
MI2C_Transmit_Byte(0b10100000)                    // Address device again
result=MI2C_Receive_Byte(1)                       // Read byte signaling this is last
For write it would be:

Code: Select all

MI2C_Start                                        // Start I2C transaction
Mi2C_Transmit_Byte(0b10100000)                    // Address device
MI2C_Transmit_Byte(address byte)                  // Select address to write to
MI2C_Transmit_Byte(data)                          // Data byte
Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEPROM Operation

Post by medelec35 »

Not disagreeing with Jac that something could be wrong in the code since Jac knows more about I2C than I do.
The only thing I can say is I tried the same hex file (compile from EEPROM read and write V2 .fcf)
on hardware and proteus, and it worked on hardware but not in proteus.
It maybe better for proteus if you do modifications Jac suggested?
Martin

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EEPROM Operation

Post by kersing »

Martin,

What is the exact hardware you tried? (Model and Manufacturer) As there may be differences in devices from different manufactuters (for the 24c04 the OP mentioned Farnell lists 4 different manufacturers)? For the Microchip 24LC512 the sequence in the transaction macros is fine. For a 24C04 made by On-Semi it won't work. (And greentech says he is using a 24C04)

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: EEPROM Operation

Post by greentech »

Then what to do? The datasheet for 24c04 advices the same sequence. why that doesn't work? i have also tried this with 24lc512 with the same results.....

Fairy

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: EEPROM Operation

Post by Spanish_dude »

Proteus has some glitch with pull up resistors.
I've had some simulation issues on one of my schematics because of that. Really annoying...

The only way to be sure your program works is by testing it on hardware.

Post Reply