File corruption and sleep mode

09 Aug 2011

Hello All,

I have a program on my mbed that runs in my car. It reads CAN maeesages from the car and at start-up loads in configuration information from files stored on the mbed. The mbed "Powers up" when the cars key is placed in the "On" position. I have had a situation come up where the key was cycled On>Off very quickly. It must of killed power from the mbed as it was reading in the configuration files because all the files were corrupted. I was able to re-create the event by pulling the power on the mbed at exactly the time it was loading the config information...

So I thought about two solutions... 1.) Add a timer circuit to my board that would provide power after the key was turned off for long enough to ensure the mbed could get through the config steps.. 2.) Have the mbed stay active as long as it is reading CAN messages... And when the messages stop, go to sleep after X mount of time...

Doing option 2 would allow me to impliment a solution now, in code, with just a simple wiring change. But I know very little about putting the mbed to sleep. Does the "Go to sleep" approach even sound plausable? Or are there things I'm overlooking?

Tim

Bottom line is this... When power is cut to the mbed while it's reading in configuration information from local files, things get corrupted... What's the easiest way to stop this from happening?

Thanks You

--

11 Aug 2011

Normally I wouldn't expect a file system to be corrupted when you are only reading from it but it could be possible for the LocalFileSystem since I am not that well versed on the memory chip used for the USB mass storage. Are you only reading from the configuration file or do you append some data to a file as well for each startup?

What type of corruption do you see? Was it just the contents of a single file that were scrambled or were you not able to even mount or list the contents of the root directory for the device?