Pic24/ds33Pic uses flash memory instead of EEPROM

Started by xvovanx, Feb 25, 2024, 06:52 PM

Previous topic - Next topic

xvovanx

Hello!
I decided to update the old project on the Pic18F8722 chip, taking the dsPIC33FJ256GP710A.
But after reading the datasheet, I was very upset that this chip only has Flash memory, which has a limited number of read/write cycles ~10,000 (for Eeprom ~1,000,000). A device can have about 100 write cycles per day, but the memory will only last 2-3 years? What to do? Having such a cool chip with 256KB memory, it's somehow stupid to install external Eeprom memory as well.

trastikata

Assign several times more space than you need for the data you have to write. I usually add a write cycles counter to the data to be saved and increment it at each write cycle. When the counter reaches the maximum write cycles, start writing at new address.

Flash memory has to be erased before you can write to it, therefore pay attention of block erase sizes.

Frequently saving data to flash memory is not so straightforward. You need to write in page sizes which is usually different size than erase block size and page addresses have to align with the correct address.

Sometimes you read the entire page in an array, then change data and the write it back again. Or you preset the entire array to 255, change positions in the array that need to be saved and write back the page array.

This is to say Flash used as EEPROM is possible but much care should be taken when you design the subs to align all erase and write addresses..

xvovanx


Stephen Moss

Quote from: xvovanx on Feb 25, 2024, 06:52 PMA device can have about 100 write cycles per day, but the memory will only last 2-3 years? What to do? Having such a cool chip with 256KB memory, it's somehow stupid to install external Eeprom memory as well.
Is the data critical, in that you have to make that many write cycles a day to minimise data loss due to power outage or is the data non critical?

If the latter than perhaps you could store the data in an array and write the array contents, that way depending on how much RAM you have to store the array contents and the amount of data required you could then write say 10 sets of data at a time, thus extending the read/write lifetime from 2-3 year to 20-30 years as you will only be doing 10 write cycles a day instead of 100. 

xvovanx

Hello!

This is a Smart Home system that has been working for me for about 10 years. Eeprom records every event (lights/sockets/water pumps/heating system/CCTV/security system/access control, etc.) to restore states after possible power failures.
For me to add Eeprom 24CXX to the project, it will be much easier  ;)