Home > pic > Will an SPI EEPROM chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM?

Will an SPI EEPROM chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM?

March 7Hits:0
Advertisement

This question already has an answer here:

  • Will an SPI flash memory chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM? 4 answers

A while back I had some intermittent trouble with the internal EEPROM of a dsPIC. Every so often, some value in the EEPROM would be found zeroed out on power-on. I tracked the problem down to when the chip lost power after the erase step of the write cycle, but before the write had completed. It was all about the timing of the power-down relative to the firmware execution, which was (in normal operation) random. I solved this by adding a buffer section to my EEPROM, to ensure that an incomplete write-cycle could be completed on restoration of power. I had to turn EEPROM writes into an atomic operation.

(For further detail, my buffering technique defines an area of persistent memory that consists of three fields: address to write to, data to be written, and a READY flag. A "write" consists of four steps: write to buffer, set READY flag, write from buffer, clear READY flag. On power-up, you check the READY flag. If it's set, execute whatever's in the buffer. This worked well in internal EEPROM.)

Now I'm using a different dsPIC without internal EEPROM, and I'm trying to use an external EEPROM chip to store persistent data. I'm wondering if I should have similar concerns. Should I be worried that my external EEPROM chip will power down mid-write and lose data, and write a fix for this in my firmware like I did for internal EEPROM? Or does the chip itself guarantee atomic write operations?

Answers

The chip cannot guarantee atomic writes - if the power goes away while it is writing (or erasing), there's nothing it can do about it.

Of course, the chip designers could implement some kind of holding store (as you have done) - but that adds cost that other users won't want to pay. Also, what happens if the power goes down whilst writing to the buffer instead of the "real" memory?

For reliable recovery of data from EEPROM there are a number of things that can be done. Let's consider for example storing an occasional counter value into the persistant storage of the EEPROM. You have to take into account both the power loss problem we are discussing here and also the write endurance characteristics of the serial EEPROM.

It is OK to use the EEPROM in a read / write mode (given that you have time to do it) as long as you make sure that you can assure that the wear out endurance for the memory cells will not be used up in the length of life of the product. As for example I have done product designs with external EEPROM such as 93C46 connected to microcontroller via 3 port pins. I have used certain locations in the EEPROM to accumulate information such as accumulated count or total time passage. I have done calculations using the endurance numbers for 93C46 and have found that if you want to ensure that a product can last for 10 years then on average you can permit the EEPROM location to be updated once each 10 minutes.

With this in mind I typically design my software so that the microcontroller maintains the current count or time accumulator in local RAM and then a timer function provides for a "once every 10 minutes" update to copy the RAM locations into the EEPROM. For many applications this simple solution is more than adequate since the occasional loss of 10 minutes of accumulation is not particularly critical.

If the count maintenance needs to be more critical however you can then arrange to have the microcontroller manage its own power off and force a final update of the EEPROM locations from RAM locations just before powering itself off.

And if even more critical maintenance is required you can arrange to have an early warning power fail interrupt that will permit the software to force an update to the EEPROM just before the microcontroller looses its blood supply of electrons.

Now there is an even more important subject to consider in using an EEPROM to maintain nonvolatile counters. This relates to how you manage the process of maintaining reliable storage of the accumulators when the power goes off just as you are in the process of writing to the EEPROM. I have addressed this problem over the years, in many projects, as follows:

Lets take the 93C46 chip as an example. It has 16 bit locations in it. I typically use 2 locations and make my accumulator be 24 bits and then compute a simple XOR type of CRC over these three bytes and plug that into the 4th byte of the 32 bits of the pair of EEPROM locations. Then when the EEPROM is written the accumulator+CRC is written to the EEPROM in two different places. (I.E. the accumulator is redundantly stored into the EEPROM). Also make sure to write your software so that write of one copy of the accumularor+CRC is completely written before the other is started. It is also a good idea to interpose a delay of some number of milliseconds between the pair of write operations.

Then at next power up when I initialize the RAM based copy of the accumulators from EEPROM I use the following concept. I read the first copy of the accululator+CRC from the EEPROM and I check the CRC. If it is correct I then use the read value of the other 24 bits as the value to write into the RAM locations. If the check of the first location proves to fail I then go read the second copy and check it. If it is OK then that becomes the value plugged into the RAM locations. If both have failed then I apply a default value to the counter in RAM such as zero or "full" count. ("full" count would apply to cases where the EEPROM location is being used to keep track if how many times are left to allow something to happen....[such as how many more boxes are allowed by before the microcontroller posts a maintenance request...etc etc].

Tags:pic, data, spi, eeprom

Related Articles

  • Will an SPI EEPROM chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM? March 7

    This question already has an answer here: Will an SPI flash memory chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM? 4 answers A while back I had some intermittent trouble with the internal EEPROM of a dsPIC. Ev

  • Will an SPI flash memory chip have the same issues with non-atomic write operations as a dsPIC's internal EEPROM?March 6

    A while back I had some intermittent trouble with the internal EEPROM of a dsPIC. Every so often, some value in the EEPROM would be found zeroed out on power-on. I tracked the problem down to when the chip lost power after the erase step of the write

  • High capacity - EEPROM chipJune 2

    I am looking for high capacity eeprom(I2C compatible) IC as an alternative to 1gb or 2gb micro SD card (data storage segment in my project) just in case I fail to interface Sdcard with pic32 mcu.. Suggestions are welcomed.. Thanks in advance.. ------

  • What is the purpose of SRAM in the DS1307 RTC chip and the onboard AT24C32N EEPROM chip??

    What is the purpose of SRAM in the DS1307 RTC chip and the onboard AT24C32N EEPROM chip??December 6

    I am going to interface a RTC to PIC18F and before doing so, I'd like to clear some doubts regarding the module and its connections. I am using the "Tiny RTC" as shown in this link!. The following questions are: What is the use of the SRAM in th

  • How are system configuration flash or eeprom chips programmed?January 5

    I've seen, quite often actually, a circuit that will have an eeprom or flash chip soldered next to the application chip. Take a look at the ESP8266, it has some kind of programmable memory that sets up the SoC. My question is how was that eeprom/flas

  • Unable to use compiler built-in functions to write to dsPIC EEPROMAugust 16

    As I mentioned here, I've been having issues with EEPROM on dsPIC30F6012A. Since my old EEPROM library was difficult to analyze and support, I went back to square one and rewrote it using the new (newer than my library!) C30 compiler built-in EEPROM

  • Are any USB-to-SPI *slave* bridge chips readily available?June 18

    I would like to interface a battery-powered device to USB, without requiring users to install drivers. Data transfer requirements are moderate, so the ~60kbytes/sec of HID mode would be fine, but I don't want to be much slower than that. The main pro

  • Switching a SPI chip between two devices?June 20

    I'm working on a project where it would be very handy to be able to automatically switch a SPI flash chip between two different devices (a programmer, and the system that's actually using it). Conceptually, this seems like a very simple task to me. I

  • Reflash Supermicro BIOS Chip with external EEPROM programmerJuly 24

    I've a Supermicro server, out of warranty, and it suicided in the last month. Yes, exactly. During a AMIBIOS update process the BIOS Watchdog has been tripped and the motherboard reseted during the flash. We ended up with a non functional motherboard

  • Help identifying this chip (EEPROM?)

    Help identifying this chip (EEPROM?)May 19

    I have a circuit board from a Stratasys UPrint SE filament cartridge, and I'm trying to talk to the EEPROM on it. This board is unlike other Stratasys boards that I've seen people hacking with, and after a day or two of failed attempts to communicate

  • Non-Volatile Serial Memory ChipMarch 29

    I need a non-voltile serial memory chip that I can clock random bits(about 500 bits) into one at a time by hand using toggle switch to clock them in . This stored bitstream is then clocked out at 20K bits/second at the push of a button, every time yo

  • Suitable small/fast EEPROM for Atmega328November 18

    Looking for recommendation on EEPROM chip, which I can connect to Atmega328. The requirements are: at least 5-10Kbyte fast reading with Atmega. I expect reading one word about 1-5us, please advise if it's possible. I am going to store set of custom d

  • How do I write to SPI flash memory?

    How do I write to SPI flash memory?December 13

    I'm working on an audio application where instead of storing audio data on an SD card (Waveshield on Arduino) I'm storing it on an SPI flash memory IC and rolling my own board with MCU, DAC, and amp. I am using a Winbond W25Q80BVSSIG. I'm pretty fami

  • Alternatives to using EEPROMFebruary 18

    As I understand it, EEPROM is a part of a computer (in my case, an AVR microcontroller) which stores data, and holds on to it even when the device completely shuts down. It allows data to be written to it, and read from it. The problem I am seeing is

  • Why is serial EEPROM preferred over parallel EEPROM?June 11

    In the wikipedia page for EEPROM: http://en.wikipedia.org/wiki/EEPROM it is given that "Parallel EEPROM devices typically have an 8-bit data bus and an address bus wide enough to cover the complete memory" and also "Operation of a parallel

  • Why use RAM IC over EEPROM IC?September 7

    I have been looking at various different external storage ICs that would work with an arduino. When I looked at the specs of some EEPROM chips and compared it to the specs of other RAM chips, I noticed that they had relatively similar specs in terms

  • Reading empty (new) AT24C16 I2C EEPROM - 0xFF or 0x00?July 30

    What byte vaule should I see when reading empty EEPROM chip via I2C? --------------Solutions------------- The way an EEPROM works, the act of erasing sets every bit to 1. When you write to it the bits that shouldn't be 1 are set to 0. It's all to do

  • How can I find out what chip is used in USB - Serial (RS232) converter from FTDI?

    How can I find out what chip is used in USB - Serial (RS232) converter from FTDI?August 28

    I have an USB <-> RS232 converter with no designation of producer on it. After plugging it into USB port on Windows Vista 64bit computer I chose an option to automatically find and install drivers from Windows Update site. Drivers (for USB Serial Co

  • Microcontroller with ADC and capable of SPI communicationDecember 24

    I am designing a system where Analog Signal ---> (ADC- Digital Data )---> UWB chip mostly WSR601 or AL6301/AL5100 Chipset Note (1): UWB is an abbrieviation for Ultra Wide Band wireless communication technology. Wireless USB chips which are being use

  • FT232R eeprom problem .. how to make PC recognize itDecember 31

    it's my first time to use FT232R .. when i connected it to the USB for the first time .. my Windows recognized it well, and its drivers were successfully installed .. and even after programming it once or twice more .. it was O.K. i tried to program

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.586 s.