Flash EEPROM component

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Flash EEPROM component

Postby kersing » Sun Dec 21, 2014 11:10 pm

Attached component provides EEPROM emulation using Flash memory on PIC24 and dsPIC controllers.

See the component help for information on use.

Feel free to use it in your projects, but please observe the license:

Code: Select all

Copyright (c) 2014, The-Box Development
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
   This product includes software developed by 'The-Box Development'.
4. Neither the name of 'The-Box Development' nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE-BOX DEVELOPMENT ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE-BOX DEVELOPMENT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Attachments
flasheeprom.fcpx
(9.86 KiB) Downloaded 310 times
These users thanked the author kersing for the post (total 8):
medelec35 (Mon Dec 22, 2014 2:19 am) • Benj (Mon Dec 22, 2014 11:08 am) • headhuntergr (Mon Dec 22, 2014 4:47 pm) • JohnCrow (Thu Dec 25, 2014 9:53 am) • Rudi (Thu Jan 15, 2015 6:36 am) • petesmart (Mon Jun 15, 2015 11:19 am) • cb28 (Tue Dec 29, 2015 12:06 pm) • leoo (Thu Jun 29, 2017 6:16 pm)
Rating: 47.06%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Emanuel Lourenco
Posts: 63
Joined: Mon Dec 23, 2013 5:51 pm
Been thanked: 8 times
Contact:

Re: Flash EEPROM component

Postby Emanuel Lourenco » Sun Jan 11, 2015 12:06 am

Hello,

I am using an DSpic33EP256MU806 but I am not able to use this component.
In the simulation gives perfectly. When I go to the chip it always displays the value 255.

I leave the program

Best Regards
Attachments
Teste.fcfx
(7.13 KiB) Downloaded 183 times

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Sun Jan 11, 2015 4:19 pm

There are a couple of possible issues with your flowchart.

1) Valor1 is not initialized. In simulation it will default to 0, on chip the value might be anything.
2) It looks like you swapped the arguments to the flasheeprom1::Write call. You are using Valor1 value as the address, not the value to store. You are reading address 1, however because Valor1 is not initialized the value (1) could be stored at any location.

Best regards,

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

― C.S. Lewis

Emanuel Lourenco
Posts: 63
Joined: Mon Dec 23, 2013 5:51 pm
Been thanked: 8 times
Contact:

Re: Flash EEPROM component

Postby Emanuel Lourenco » Sun Jan 11, 2015 11:58 pm

Hey

I am not able to get this component working. They could do a sample program?

Best Regards

Emanuel Lourenco
Posts: 63
Joined: Mon Dec 23, 2013 5:51 pm
Been thanked: 8 times
Contact:

Re: Flash EEPROM component

Postby Emanuel Lourenco » Thu Jan 15, 2015 12:37 am

hi
I'm having trouble in it.
Always gives me 255.

I ask you to help me as fast as possible.

I'm desperate.

Best Regardshi
Attachments
Teste.fcfx
(7.29 KiB) Downloaded 178 times

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: Flash EEPROM component

Postby Rudi » Thu Jan 15, 2015 6:39 am

kersing wrote:Attached component provides EEPROM emulation using Flash memory on PIC24 and dsPIC controllers.



wow!
hi jac,
happy new year - have seen just in time - not seen at time as you post - this is a fine after christmas gift for me!
many thank for your work - will test at weekend
best wishes!
rudi ;-)

Emanuel Lourenco
Posts: 63
Joined: Mon Dec 23, 2013 5:51 pm
Been thanked: 8 times
Contact:

Re: Flash EEPROM component

Postby Emanuel Lourenco » Sat Feb 07, 2015 2:14 pm

Hello,
No one can help me?
I am in need to solve this problem.
Always gives me 255 in variable.
Help me please
Attachments
Teste.fcfx
(7.29 KiB) Downloaded 153 times

User avatar
Benj
Matrix Staff
Posts: 13946
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4224 times
Been thanked: 3979 times
Contact:

Re: Flash EEPROM component

Postby Benj » Mon Apr 27, 2015 2:17 pm

Hello,

For record I've just used this component for a project using the dsPIC33EP256GP502 and the component worked very well indeed. Each value will be reset to 65535 (255 if reading into a byte) when erasing the program memory.

To work around this I have a condition on startup which checks to see if the first value is 65535 or 255 for a byte. If it is then I write all the default values. The next power on the defaults are as they should be.

Many thanks Kersing.
These users thanked the author Benj for the post (total 4):
kersing (Mon Apr 27, 2015 2:25 pm) • petesmart (Sun Jun 21, 2015 10:35 am) • medelec35 (Sat Jan 16, 2016 5:29 pm) • Rudi (Sun Jan 24, 2016 3:47 am)
Rating: 23.53%
 

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Thu Jan 14, 2016 1:43 am

I'm having trouble with the flash EEPROM component 1 am using the flash memory addresses starting at 98304-98385 and I will need to use more addresses.
When I compile 19% of program memory use, from then on the program compiles but does not work the microcontroller.
How do I decide if I still have to use more flash memory addresses and more program memory?
Google Tradutor para empresas:Google Toolkit de tradução para appsTradutor de sitesGlobal Market Finder
Desativar tradução instantâneaSobre o Google TradutorCelularComunidadePrivacidade e TermosAjudaEnviar feedback

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Doubts component Flasheeprom1 and dsPIC33

Postby RLOPES780 » Thu Jan 14, 2016 12:21 pm

I am using component flasheeprom1 and dspic33fj256gp710.
I must use many flash memory addresses.
I'm still in the program from the beginning and I am using early flash addresses 98304 to 98385.
From this point on qualquem new macro to create the program compiles but when I record in the pic it not roda.Se remove the macro or macro and compile when I record in the pic it runs.
It seems that the new macro occupies the space of the flash memory.
Doubts?
How much flash memory can use the dsPIC?
I'll have to use an external memory which already takes many flash addresses?
If so you could use external memory to solve this problem?

Grateful;

Ricardo.

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Doubts component Flasheeprom1 and dsPIC33

Postby kersing » Thu Jan 14, 2016 7:13 pm

Posting the same question twice does not get it answered sooner. I'm merging this question with the other one.

Please provide the output of a successful compile (without the flash component) so I'm able to determine a new address you can safely use. If you want to try yourself, get the data sheet of the dspic33fj256gp710 and check the memory lay out on page 33. A location that is probably save to use is 163840.

(You are currently using flash 98304 to about 106496, not to 98385)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Thu Jan 14, 2016 8:52 pm

Hello Kersing.

What is the starting address and the last address that possso use as flash?
What is the maximum capacity?

Ricardo.

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Thu Jan 14, 2016 9:03 pm

Ricardo,

Check the data sheet for the device information.

For the component, it allows 253 values to be stored (addresses 0 - 252). The values are 16 bit wide. To allow for wear levelling of the flash the component uses 2K - 8K flash memory depending on the device used.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Thu Jan 14, 2016 9:26 pm

Do not speak English, sorry about that use the translator.
Just wanted to know the initial and final address I can use.

Ricardo.

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Thu Jan 14, 2016 9:32 pm

The start addresses depend on the amount of flash required for your program, which I don't know. I've provided the last address I think you can safely use in a previous message (163840).
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Thu Jan 14, 2016 9:50 pm

I need a maximum of 250 endereços.Entao can use as a starting 163840 and 164090 end?

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Thu Jan 14, 2016 11:08 pm

That is not the way the component works. It needs the amount of memory specified. If you want to use only a few words you can not use the component and you need to find another way to store the information.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Fri Jan 15, 2016 2:55 pm

Hello Kersing;

The dsPIC I'm using has memory of 256k.
My program at most had come to 150k.
Not could be used to flash EPROM 200k ahead?
I do not understand about it.
Otherwise I'll have to use a memory i2c type 24lc. Has some component that communicates with memory i2c?
Another option is to use a pic ds30f6012 that already has eprom?
Can you give me an opinion?

Ricardo.

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Fri Jan 15, 2016 3:33 pm

Your chip has 256KB flash and uses 3 bytes for every 2 addresses, so effectively the highest address is 175103. However, in the last page a couple of bytes are used so the flash component can not use that page. So I suggested using flash a little before that. The suggested address is still well clear of your program.

I suggest you try reading a bit about the dsPIC33 and PIC24 flash memory organisation. The program memory reference manual would be a good place to start. The microchip website has a lot of information regarding the features of each device on the devices specification page in the documentation section.

For your other questions, both options are valid and I have no opinion which would be better. You can check for an i2c memory component yourself, use the component search option in Flowcode and if nothing is found search the forum, specifically the User Components part.
These users thanked the author kersing for the post (total 2):
medelec35 (Sat Jan 16, 2016 5:28 pm) • Rudi (Sun Jan 24, 2016 3:49 am)
Rating: 11.76%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Sat Jan 16, 2016 3:03 pm

Hello Kersing;
My problem is this.
I need to store 32 variables 8-bit ex 9999999.9 and these variables are float.
I am using a flash EPROM memory address to store each of the variables then 32 x8 then will use 256 Flash EPROM memory addresses what I'm not getting it.
Could quardar an entire variable in only one address memoria.Mas the address is 16 bits and supports only 65536.Como could do so using the flash minimum possible?

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Sat Jan 16, 2016 5:27 pm

RLOPES780 wrote:I need to store 32 variables 8-bit ex 9999999.9 and these variables are float.


Float is not 8 bit. Do you need to store float or 8 bit?

RLOPES780 wrote:I am using a flash EPROM memory address to store each of the variables then 32 x8 then will use 256 Flash EPROM memory addresses what I'm not getting it.


As stated before, at each address you can store 16 bits (unsigned int), so 32x8 / 2 = 128 cells.

RLOPES780 wrote:Como could do so using the flash minimum possible?


The component requires the earlier stated amount of memory. If you can not spare 8K from 256K memory or the storage required exceeds 253x16 bits you will need another solution. You could look at external SPI or I2C memory or sdcard (component available for sdcard)
These users thanked the author kersing for the post:
medelec35 (Sat Jan 16, 2016 5:28 pm)
Rating: 5.88%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Sun Jan 17, 2016 9:51 pm

Hello kersing;
I know I am bothering you on this subject!
But I chose the dsPIC33 by the amount of memory 256k and be Flash.
I thought that would facilitate my job as a beginner.
I am sending a copy of the program that is not finalized.
I believe we still miss about 70% to finish.
I am using for enquando the addresses of 163,840 to 163,895 and would need to use at most to complete the program over a 50 addresses.
If you have no solution I will try to change the pic 30f6040 that has onbord memory.
I would love to continue with the dsPIC33 as I am having a optimal performance with it.But not even know how to start using an I2C interface with an EEPROM 24lc which would save all my work.

Grateful;

Ricardo
Attachments
Flowcode1.fcfx
(596.78 KiB) Downloaded 122 times

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Sun Jan 17, 2016 9:55 pm

sorry dspic30f6014

RLOPES780
Posts: 98
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 2 times
Contact:

Re: Flash EEPROM component

Postby RLOPES780 » Mon Jan 18, 2016 1:26 am

I2c is attached example is not Kersing?
I'll try to do!

Ricardo.
Attachments
3. EEPROM read and write_v6.fcfx
(14.51 KiB) Downloaded 132 times

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: Flash EEPROM component

Postby kersing » Mon Jan 18, 2016 11:19 pm

That code is for I2C. You will need to check the data sheet of I2C storage device you want to use to check if it accepts the command and addresses in the format included.

Looking at your flowchart I am wondering if you should not try to optimize a bit. Example CONVERTE_FREQ_ASC_TO_INT, you are comparing F_MIL with values and assigning a new value. However it looks like a calculation with F_MIL = F_MIL - 48 should get rid of the entire first set of nested decision icons. Same with F_CEN = F_CEN - 48 for the second set etc etc. Result is a few bytes of code (occupying flash) compared to tens of bytes.

If I remove the DS3231 component (I do not have that component on my system so I can not compile with it in the code) the compiled code uses just 43K of flash, so I do not understand you issue with the flash eeprom component and the amount of flash memory used. Please post the lines starting with Program Memory to Total program memory used (byte) if you think you have an issue.
These users thanked the author kersing for the post:
medelec35 (Sat Feb 06, 2016 3:30 pm)
Rating: 5.88%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis