Page 1 of 2
EEPROM Operation
Posted: Sun Nov 11, 2012 2:07 pm
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.
Re: EEPROM OPERATION
Posted: Sun Nov 11, 2012 2:26 pm
by JohnCrow
Hi
Can you post your flowchart so we can see how you are trying to store values in the eeprom
Re: EEPROM OPERATION
Posted: Sun Nov 11, 2012 3:30 pm
by Enamul
Hello
Here is an example code for EEPROM using FCV4 so can be used in FCV5..
Re: EEPROM OPERATION
Posted: Sun Nov 11, 2012 5:49 pm
by Steve001
Re: EEPROM OPERATION
Posted: Mon Nov 12, 2012 3:31 am
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...
Re: EEPROM OPERATION
Posted: Tue Nov 13, 2012 9:04 pm
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
Re: EEPROM Operation
Posted: Tue Jun 18, 2013 4:06 pm
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.....
Re: EEPROM Operation
Posted: Thu Jun 27, 2013 11:23 am
by Enamul
Have you tried this example? I have used that and it works fine for me.
Re: EEPROM Operation
Posted: Thu Jul 25, 2013 8:54 am
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"
Re: EEPROM Operation
Posted: Thu Jul 25, 2013 10:52 am
by greentech
Aint working for me, ACK returns 1,1,1,1 read operation returns 255.
Re: EEPROM Operation
Posted: Sat Jul 27, 2013 8:01 am
by greentech
any suggestions?
Re: EEPROM Operation
Posted: Sat Jul 27, 2013 2:22 pm
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
Re: EEPROM Operation
Posted: Wed Jul 31, 2013 4:22 pm
by greentech
Thanks Martin,
Ill have to order this chip, ill update u soon regarding this.
Kind Regards,
Fairy.
Re: EEPROM Operation
Posted: Wed Jul 31, 2013 4:26 pm
by medelec35
No probs.
What chip have you got?
I thought you had the one I tested, thats why I posted about it.
Re: EEPROM Operation
Posted: Wed Jul 31, 2013 8:01 pm
by greentech
martin i was working with 24C04
Re: EEPROM Operation
Posted: Wed Jul 31, 2013 11:04 pm
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?
Re: EEPROM Operation
Posted: Tue Aug 06, 2013 10:53 am
by greentech
this program doesnt work at all. each time i load it it returns same 255 value. what value are u getting?
Re: EEPROM Operation
Posted: Tue Aug 06, 2013 1:21 pm
by kersing
Could you post a diagram showing the way you connected your hardware and the flow code file you are using?
Re: EEPROM Operation
Posted: Wed Aug 07, 2013 6:54 am
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
Re: EEPROM Operation
Posted: Wed Aug 07, 2013 7:38 am
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
Re: EEPROM Operation
Posted: Wed Aug 07, 2013 10:22 am
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
Re: EEPROM Operation
Posted: Wed Aug 07, 2013 7:29 pm
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?
Re: EEPROM Operation
Posted: Wed Aug 07, 2013 7:45 pm
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
Re: EEPROM Operation
Posted: Thu Aug 08, 2013 5:39 am
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
Re: EEPROM Operation
Posted: Thu Aug 08, 2013 9:32 am
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.