Hi all, I want to store some values on an MPC5xx based controller. I want my code to maintain the last set of values on a few variables when it is shut down, and these values should be accessed the next time the controller is started. How can it be done on the normal Flash memory? Or would I need some other hardware?
Ordinary flash takes a fair bit of time for writing, complicating the power-supply design.. A simpler solution is a small battery-backed RAM of the type used to remember the BIOS settings of a desktop computer.
This newsgroup is more about theory and techniques of control systems themselves, not the hardware that implements them. Where discussions of hardware are undertaken it is usually about PLCs, not embedded control. So this question is a much better fit for comp.arch.embedded and I have taken the liberty of cross-posting my reply over there.
Usually when you do this sort of thing with Flash you reserve one sector for parameters. When a parameter changes you have to erase the whole sector and re-write it with a copy that has your new parameter embedded in it.
Often if you know ahead of time that you need to save parameters you'll design your board with a serial EEPROM, which lets you manage just the memory space for the parameter you're changing instead of the whole block. You can even get fancy and do cell leveling to extend the life of the EEPROM.
Attempting to store variables in the flash of the MPC5xx series is asking for trouble. The flash on these parts is only really suitable for program storage, especially on the MPC555 which requires very careful programming and has a woeful write limit (100 cycles guaranteed).
Unless you have an absolute requirement for not modifying a board design, you should use a serial EEPROM for data storage. I recommend connecting it to one of the SPI ports for easy access.
I used to buy a 256-byte DIP RAM chip with a lithium battery built in. I forget the maker, but no matter. A 32-kilobyte chip will run off a lithium button cell for about ten years if the chip is used only for safe storage, and a bit less if the parameters are accessed from it in use. Hardware that senses the impending shutdown and blocks the write line before the supply drops so low that proper operation can't be guaranteed is a very worthwhile precaution.
Dallas used to make them -- I don't know if they survived the transition to Maxim, however. I don't like them because they're big and because I have less faith in the battery than I do in an EEPROM cell.
And some sort of hardware protection on write is an essential thing, to be sure.
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.