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
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

Post by greentech »

thanks spanish, ill definitely test it on the real hardware now and get back to u.

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

Re: EEPROM Operation

Post by kersing »

greentech wrote: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
Which data sheet? Do you have a link to the one for your device? As is mentioned before the are different manufacturers and the devices might not be compatible.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

medelec35
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

Post by medelec35 »

kersing wrote:Martin,

What is the exact hardware you tried? (Model and Manufacturer)
Sorry for the delay Jac.
I'm using
Microchip 24LC512
Data sheet:
http://ww1.microchip.com/downloads/en/D ... 21754M.pdf

Last time I tried, it took a few attempts to display the correct information.
It was on a separate bread board to microcontroller, so could have been caused by stray capacitance, or as Jac has been saying flowchart is not correct?

Hope this helps

Martin
Martin

medelec35
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

Post by medelec35 »

I'm looking into this more.

I can confirm that reading EEPROM works 100% of the time.
It looks like the issue is writing to EEPROM.
I changed 2013 to a different number to test and the number read was still 2013.
So the reason I thought it was working is because with a previous flowchart I must of successful programmed with 2013.
So I'm changing flowchart to take that into account.

At least that could be one reason your still getting 255's and I'm not?

So I will see if I can sort out flowchart and only when working 100% I will post it.

I do want to solve this...determined :)
Martin

medelec35
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

Post by medelec35 »

There was a bug in 3. EEPROM read and write.fcf that greentech posted on Wed Aug 07, 2013 6:54 am

I have corrected bug, and now my hardware works 100% of the time.
To confirm both read and write works, I have been changing the data values.
Read now always matches write.

Still not sure if it will simulate or not?

I will see if flowchart works with other I2C EEPROMs.
Attachments
3. EEPROM read and write V3.fcf
(19.85 KiB) Downloaded 366 times
Martin

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hello,

I tried a porting in Flowcode 10 but without a successful result.
It seems that the data is not stored in the eeprom locations.
Please help me.

Thank you!
Attachments
test eeprom.fcfx
(19.08 KiB) Downloaded 41 times

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hello,
I don't know if the flowchart is good, I ordered eeprom memory 24LC512.

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hello,
They came eeprom 24LC512, I put them in the circuit, but without result. Is there someone who can correct the flowchart? What must be done? The flowchart is made in Flowcode 10 after "3. EEPROM read and write V3".
Attachments
eeprom test.png
eeprom test.png (1.13 MiB) Viewed 2252 times

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

Hi,

You look to be using i2c generic read/write register The eeprom needs more than this to work correctly. Have you tried the eeprom component?

Have a look at viewtopic.php?t=22422 for some more detail

Martin

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hello,

Thanks for the reply and the link. Can 24LC512 be inserted in your program?

Thank you!

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

I tried the official component - good to check you have comms first :-)

After a little fiddling - using an Arduino Uno - and enabling the inbuild pull-ups (I also needed external pull-ups but it wouldn't work with either the enable or the hardware removed - very odd, but the resistors I used were just two at 'random')

Then - address - I had pins 1 and 2 connected to VCC (using an old project with 4 x 256Mb chips) so set address to 3 for the component. Set this property to 0 unless you have a0/a1 (pins 1 or 2) connected to VCC.

Then - a simple write followed by a read. I read the data twice, once a byte at a time, and once using the block read. The data is sent to UART at 115200.

So - this is using an 24LC256 but either should work (this using v10)

Martin
Attachments
eeprom.fcfx
(16.17 KiB) Downloaded 38 times

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hi,
Thank you very much for your help and answer.
All the best!

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Hi Martin

I did the porting on the PIC16F877A, without any modification, but it does not compile, I am attaching the image. What should I do? I am using Flowcode 10.
Attachments
does not compile.png
does not compile.png (276.01 KiB) Viewed 2202 times

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

You'll need to change the i2c pins (and the eeprom address) in the component properties.

Also delete the macro pullup (and the two calls to it). You'll need to have pull-up resistors as per i2c.

Martin

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

The I2C pins in the component properties show that they are connected to the C4 SDA port and the C3 SCL port for the PIC16F877A and the address goes to 0?

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

Yes - if that's where they are connected. Adress should probably be 0 (pins 1 and two floating or gnd)

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

It does not compile, the same message as the picture above. Please help me to compile.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

Will try when I get home this afternoon.

I have a few PICs I can try too?

Martin

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

Try this flowchart.
Attachments
eeprom(1).fcfx
(16.23 KiB) Downloaded 38 times

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

This is the Flowcode message in the image below.
Attachments
does not compile 2.png
does not compile 2.png (278.3 KiB) Viewed 2183 times

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

Delete the pullup macro too...

I also output the data to UART - change this to use your display instead ..

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

But in the program UART transmits not receives data. This is what the flowchart looks like.
(908) exit status = 1
(908) exit status = 1

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: EEPROM Operation

Post by mnf »

Just tried compiling and seems the PIC you have has too little RAM to use the component.

I stripped everything out - apart from Read and Write of 10 bytes (no display etc) - and get an error insufficient memory to allocate _FCL_BUFF (130 bytes) - which would (space permitting) be used by the Page Read and Write functions.

Options:

1) Use a PIC with more memory.
2) Modify the component - remove the 'page' functions and create a new 'cut-down' component. MatrixTSL now kindly supply all the source code for the components.
3) Use my code from the above link - this did have 'block' read and write functions, but relied on the space from the 'caller'
4) Depending on how much data you want to save - use the PICs internal eeprom (the PIC has 256 bytes available)

Looking at the data sheet - the MCU you are using should have 368 bytes of RAM - so I'm a little surprised it doesn't allow this to work, so some memory being used by i2c buffers?

Martin

samtin
Posts: 26
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time

Re: EEPROM Operation

Post by samtin »

I use PIC16F877A for the test, for microcontrollers with RAM and reduced eeprom I will use external eeprom. I saw the source code on the wiki, can it be found elsewhere?

Thank you again for your help

Post Reply