Hello,
I've got some code that saves setup information to flash if the user wants. I save a code to a memory location to let the software know that whether setup information is available or not. If not, I use defaults.
Is there some way on the UVision IDE that will automatically fill a segment of memory with a byte code when I reprogram? Without this capability, the code believes that there are always saved settings and this would be the quick fix.
Thanks in advance, Matt
Isn't your flash 0xff-filled when you receive the processor?
In that case, it should be enough to define a flag byte in the data save area. As soon as you save configuration, you set this byte to a value different from 0xff.
If it is dangerous for your application to run with incorrect configuration, you should store a CRC32, MD5 or Adler-32 or similar in the data save area, to allow you to check if the data is valid. Avoid using a simple check-sum - they give too many false matches!
Agreed on the checksums,etc.
The first time I get the chip, yes it's blank / filled. But while developing and burning new code (less than 8k of stuff, I'm storing config up at 0x3FFF, so no worries about conflicts) then a saved profile at 0x3FFF doesn't get automatically cleared to 0xFF's. So I have to use a commmand to wipe that area, but I'd rather like to know for sure that when I reprogram a chip that the configuration page will be completely cleared (in case I forget).
Wouldn't your flash programming kit's "erase device" handle that already?
If you really need this, you can always write a little asm module with a couple of
DB 0xff
at the address you want cleared, and link it with your program.
Agreed. I have a manual erase, was looking for a button that automatically linked it to the download. I like your idea of the ASM code however.
Thanks, Matt
Any programmer software worth its salt will have a "full job" kind of button, which runs a complete sequence of erase, blank-check, reprogram, and possibly a verify. Use it.