Store text in eeprom

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

kunibabina
Posts: 11
Joined: Thu Sep 16, 2010 12:00 am
Contact:

Store text in eeprom

Postby kunibabina » Sun Oct 03, 2010 1:57 pm

How to store text in eeprom any example, esp. any sentence ?

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

Re: Store text in eeprom

Postby Benj » Mon Oct 04, 2010 8:31 am

Hello,

You would need to create a macro to read a string from the EEPROM and a macro to write strings to the EEPROM.

Strings are terminated with a 0 so you would have to step through the string writing bytes to the EEPROM until you reach the 0 at the end. If you also save the 0 at the end then your read back macro can count 0's to get to the right string in the EEPROM and then starting reading back the bytes into a string variable until the next 0 in the EEPROM is found.

kunibabina
Posts: 11
Joined: Thu Sep 16, 2010 12:00 am
Contact:

Re: Store text in eeprom

Postby kunibabina » Mon Oct 04, 2010 3:31 pm

Can you post any example ?

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

Re: Store text in eeprom

Postby Benj » Mon Oct 04, 2010 5:21 pm

Hello,

This example writes 3 strings to the EEPROM at the start of the program. You must write the strings into EEPROM at the beginning of the program using increasing index numbers starting from 0. You will not be able to edit the strings during operation unless they remain a fixed length otherwise you will either start overwriting other strings or cause corruption in the index search routine. You can disable the EEPROM being wiped during reprogramming if you are using the EB006 by clicking Chip -> Configure -> Options.

You can store as many strings you like using this method up to the limits of the EEPROM in your device. At the moment you loose a byte of EEPROM memory for every string to store the terminating 0. Another method would be to create an array of byte variables where each element contains the length of a string in EEPROM. This would allow the terminating 0's to be removed from the EEPROM at the expense of more RAM usage.
Attachments
EEPROM - strings.fcf
(10.5 KiB) Downloaded 635 times