Well I hope this question fits to Stackoverflow ( if otherwise, I want to apologize already )
I have can C8051F340 Microcontroller from Silabs. I wrote a little Interface which stores Information in the non-volatile flash memory from the uC. Now as in the data sheet described I save all the data in between the addresses 0x0200 - 0x0300. To copy my data there I just use memcpy.
char xdata *ptr_selection = 0x0210;
// Some other code here
memcpy (ptr_selection, writeBuffer, sizeof (writeBuffer));
Well the copying itself works well ( I looked up at the flash memory and it saved my data right ) - If I now disconnect my uC and connect it again in like 5 secs, the data is still there. But if I leave it disconnected any longer my data gets more or less "resetted" - that means it gets everytime almost the same "reset values". so what am I doing wrong? I mean isnt the flash data non volatile or did I get something wrong?
Based on the code you displayed in your question, you are trying to write to external data (xdata), which is RAM, not non-volatile flash memory. The reason the data disappears after a few seconds, is the power supply capacitor still powers the chip long enough to keep the internal RAM alive.
To write to flash memory, you need to follow a specific protocol to unlock the flash programming circuitry, then erase the area you will be writing to, and then write the bytes using MOVX instructions as described in Section 12 of the datasheet.
This Silicon Labs application note "Writing to Flash from Firmware" describes the process in detail.