Where can I store an Array for further use?

Hey y'all! Probably this was already answered in another way or in another topic, but i couldn't find nothing related to this here. (maybe i wasn't looking in the right place, anyway), I'm working on a MIDi controlled foot switch, and in this project, i have an array that saves the value of the output (HIGH or LOW, works with 1 or 0 also) for 48 different patches. The values for the patches are already declared on the array, but can be modified when the program is running.

When I shut the power down, i loose every change made to that array, having it back to the declaration values on the code when i turn it on again.

I got a MicroSD module here, and tried some options, writing it to a TXT file and then reading back again, but until now is not working as expected. I can write it but can't read it back and store it.

I'd like to know if there's a better way of doing this, maybe without de SD card. I know that i can write it in the EEPROM, but i'm afraid that i'll exceed 100.000 writes, once the code automatically saves the configuration after each patch change, so i'm afraid this may not be the best way.

Where would you store it??

Thanks!

I wold do it in EEPROM. 100,000 is a lot of writes. Work out how often you would change the patch table. If it is 5 times a day then that makes 20,000 days. Assuming you use it every day (unlikely) that makes if 20,000/365 = 54 years. 20 times a day still makes it over 10 years of continued use.

You can extent the life by moving the patch table around in EEPROM to even out the wear. Examples of this online, as you are only talking about 48/8 = 6 bytes of data.

mauriloureiro: Hey y'all! Probably this was already answered in another way or in another topic, but i couldn't find nothing related to this here. (maybe i wasn't looking in the right place, anyway), I'm working on a MIDi controlled foot switch, and in this project, i have an array that saves the value of the output (HIGH or LOW, works with 1 or 0 also) for 48 different patches. The values for the patches are already declared on the array, but can be modified when the program is running.

When I shut the power down, i loose every change made to that array, having it back to the declaration values on the code when i turn it on again.

I got a MicroSD module here, and tried some options, writing it to a TXT file and then reading back again, but until now is not working as expected. I can write it but can't read it back and store it.

I'd like to know if there's a better way of doing this, maybe without de SD card. I know that i can write it in the EEPROM, but i'm afraid that i'll exceed 100.000 writes, once the code automatically saves the configuration after each patch change, so i'm afraid this may not be the best way.

Where would you store it??

Thanks!

The bigger question is how much hardware do you have?

In most of My projects I include a RTCC, most have at least 64bytes of battery backed RAM included. This RAM has an infinite number of rewrites possible. So I could store your 48 bits of data into 6 bytes. The value of the RAM is saved until the battery fails, (3yrs).

I usually also include a 24LC512 EEPROM (64k bytes) for long term storage(MicroChip states, over 1 million erase/write cycles, and data retention of over 200 years), this EEPROM can be modified approximately one million times. Since this chip has 64k of space, an you are worried about wearing out memory cells, use a two step process. Use the first two bytes as an pointer to where your 6 byte patch table is stored. every time you power up, read the last patch table, increment the storage location. Every time you change the value of your patch table write it to the current storage location. Every power cycle will use a 'new' block. Whenever your device powers up, it will be as if a new memory chip has been installed. after 10k power cycles you will start reusing the 'old' locations. But, I highly doubt that you will use any single block a million times?

So this method would allow 10,000 * 1,000,000 patch modifications before the minimum device endurance would be exceeded. So if you modified your patch table once every second, it would take you 317 years to wear out the EEPROM.

Chuck.

but until now is not working as expected. I can write it but can't read it back and store it.

So, the code you didn't post does something you didn't describe. You expect it to do something that you didn't describe. All we know is that what it actually does is not what you expect. Not really useful in terms of being able to help you make the code do what you expect - whether that means changing the code or changing your expectations.

You could use an external FRAM also. Fast access like SRAM, with EEPRROM nonvolatility: 10 trillion to 100 trillion writes.