Christopher Wang

Flash One-Time Initialization

Discussion created by Christopher Wang on Mar 2, 2006
Latest reply on Mar 3, 2006 by Christopher Wang

I'm using the 56F807 and would like a way to know whether the chip has been powered on/the code has been run before.

Basically, I'm storing a bunch of parameters in the data flash and I would like to know in my C code if the parameter addresses in flash are valid (having been initialized by being run once before) or if I need to initialize them programmatically, because they are uninitialized.

I know of two ways to solve this problem, that if possible I'd like to avoid:

1) Custom write some addresses in the flash to say they haven't been initialized, ie., writing 0xdead 0xbeef to a couple words at a specified location and then on the first time power up (and every powered up), check those addresses and write them to be 0x0 if they aren't. The problem with this is, as I understand it, I would have to re-code the s-rec download program to custom write those addresses, and I would like to avoid doing this if possible.

2) Specify the addresses of my parameters, by default in the code, and then, I believe, when I change those, I would also need to change the constants in flash program memory. This solution, as I understand it, just scares me.

I would appreciate any suggestions or thoughts!