We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I seem to be chasing my tail on this problem. I'm trying to store floating point constants to the flash on a Cygnal C8051F005 over the serial port. It seems to work if I always erase the page first but if I don't I get some pretty weird results. I don't necessarily want to erase previously stored data. Does anyone have any code examples that may be helpful. Thanks in advance.
According to the data sheet on this part "Writes to Flash can clear bits but cannot set them. Only an erase operation can set bits in Flash. Therefore, the byte location to be programmed must be erased before a new value can be written." So if you try to just write, you will get the and of the previous contents and the current byte to be written. This is typical of how flash memories operate...
Dunno about this particulat case, but in my previous experience with Flash it has always been necessary to erase first before writing: Erasing sets all bits to '1' (ie, all bytes to 0xFF); programming can only clear bits from '1' to '0' - it can't change a '0' to a '1'. Would that explain the results you're seeing? BTW: I can't see that the type of your data (float) would have any relevance?
You should be aware that flash memory also has a limited number of erase/write cycles. You cannot treat it as if it is RAM, or you will quickly be unable to write anything to the device. Check the cygnal data sheet(s) from their website: http://www.cygnal.com