To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.
Dimer
Posted: Oct 17, 2005 - 09:36 AM
Does anyone have any sample code using a portion of the Data Flash for Configuration settings. I tried to modifying the linker cmd file as follows
.x_flash_ROM (R) : ORIGIN = 0x1000, LENGTH = 0x0E00
.x_config_ROM (R) : ORIGIN = 0x1E00, LENGTH = 0x0200
to give me a 1K block at the top of the data flash section. I'm not quite sure if this is the right approach.
Next I used the IntFlash bean to generate some code for reading and writing to this configuration section.
Also I declared a static structure to hold my configuration defaults.
//Config Defaults
static const IMAGE_RAM_STRUCT DefaultCfg =
{
(byte)0xA5,
(byte)0, (byte)0, (byte)15, (byte)5, (byte)20, (byte)0,
(int)-87, (int)191, (int)0, (int)191, (int)-87, (int)6200, (int)16500
};
I am trying to copy the defaults in this structure to the flash I set aside earlier. Is the following legal?
WriteBlock((word)&DefaultConfig,(0x1E00*2),sizeof(IMAGE_RAM_STRUCT));
Am I passing in the source address correctly? Simply casting the address to a word?
Any specific help on these issues or general comments on a better way to save configuration settings will be most appreciated.
MMCLAUGHLIN
Posted: Oct 17, 2005 - 01:18 PM
I used the 56F8357 and I used the processor expert. Doing it that way, I changed the build options of the cpu to include a flash_data at 2000h. When I wrote to it I used SetBlockFlash Method. You'll need to make sure you've erased the flash ahead if necessary and check the global protection bit. Hope this helps some.