Writing a couple of variables to flash within the application

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi all,

I've got the following problem:
In case of power failure, I need to write a couple of variables and parameters to the internal flash. So that the application may start directly from where it left after power up.

So, basically my questions are: How can I write to flash? And how can I read from flash?

I tried a couple of things. Amongst them I tried "creating a special section". It seems that this doesn't do the trick. Or I am simply missing something.
So it would be great if anybody could give me some hints on how to read or write flash.

I am using the xe162fm (xe166 family) and tasking vx.

Thanks in advance,
Sebastian
0 Likes
2 Replies
Not applicable
Hi Sebastian,

You need to use the command sequence to write data into the flash.
More information is available in the User Manual under chapter Embedded Flash Memory.
Please mind that you can't write to the same address again without erasing it.
If you are using Keil uVision, they do provide the flash driver.
You can find it in \Keil\C166\Flash\XE16xFM - FlashDev.c
To read from Flash, you can read it directly with pointer to the address.
0 Likes
Not applicable
Thanks a lot.
I had a look in the Programmer's guide and the Data sheet. But I missed the user's manual 😞
Damn rookie mistakes.
0 Likes