Hi, all.
In previous projects, I've found that many power outages are so short that RAM values are reliably maintained, even though prudence dictated stopping the CPU when power dropped below a certain level. If power was again restored within seconds, a surprisingly frequent situation, a quick check of RAM -- e.g., a checksum of a specific area -- if successful, can allow the program to resume as though nothing had happened. This is the desired result, since going through a full restart may have unpleasant side-effects, including annoying the user.
Unfortunately, the M5223X CW project startup code zeroes RAM before allowing any user-defined procedures to run. This is one way to guarantee that external C variables are initialized to zero by default, as required by C semantics. However, it prevents using my old assembly-language based technique for a silent restart after a very brief outage.
So I've got three questions:
1) Is it possible to protect a specified part of RAM from being zeroed on power up? And, of course, it has to be possible to specify which variables are to be put into this part of RAM.
2) Is there some other reasonable way during power up to tell that power has been down for a very short time, at most a few seconds? If this were possible, I could simply save critical data in FLASH as power went down and restore it after short outages.
3) Is there some other way to respond to failing power that prevents erratic behavior but does not cause a full reset if power comes back quickly?
Thanks for any suggestions.
- Richard