EEPROM Operation
EEPROM Operation
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.
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.
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: EEPROM OPERATION
Hi
Can you post your flowchart so we can see how you are trying to store values in the eeprom
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 !
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: EEPROM OPERATION
Hello
Here is an example code for EEPROM using FCV4 so can be used in FCV5..
Here is an example code for EEPROM using FCV4 so can be used in FCV5..
- Attachments
-
- EEPROM.fcf
- (6 KiB) Downloaded 809 times
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: EEPROM OPERATION
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...
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...
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: EEPROM OPERATION
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
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
Success always occurs in private and failure in full view.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: EEPROM Operation
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 743 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM Operation
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
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 515 times
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM Operation
No probs.
What chip have you got?
I thought you had the one I tested, thats why I posted about it.
What chip have you got?
I thought you had the one I tested, thats why I posted about it.
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM Operation
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?
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
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: EEPROM Operation
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
― C.S. Lewis
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
Re: EEPROM Operation
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 391 times
-
- eeprom.jpg (141.6 KiB) Viewed 21201 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM Operation
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
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
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: EEPROM Operation
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:
For write it would be:
Regards,
Jac
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
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
Jac
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM Operation
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?
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
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: EEPROM Operation
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
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
― C.S. Lewis
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: EEPROM Operation
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.
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.