- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
Im trying to write and read Flash. But it looks only reading works.
I have
/* Flash constants */
#define FLASH_ROW_SIZE_BYTES CY_FLASH_SIZEOF_ROW
#define FLASH_ALIGNED __attribute__ ((aligned (FLASH_ROW_SIZE_BYTES)))
static const uint8 FLASH_ALIGNED flashRowDataFLASH[FLASH_ROW_SIZE_BYTES]= {2}
/* Flash data write constants */
#define FLASH_DATA_BASE_ADDRESS_BYTE (uint32) (&flashRowDataFLASH)
#define FLASH_DATA_BASE_ADDRESS_ROW FLASH_DATA_BASE_ADDRESS_BYTE / FLASH_ROW_SIZE_BYTES
Read as:
a = flashRowDataFLASH[0]; and get the value 2
For write:
uint8 eepromArray[CY_FLASH_SIZEOF_ROW];
eepromArray[0] = 5;
uint8 flashWriteResult;
flashWriteResult = CySysFlashWriteRow(FLASH_DATA_BASE_ADDRESS_ROW, eepromArray);
But after a power off-on and read the value 2 is read again not 5 as expected.
Could someone tell me please what Im doing wrong ?
Thanks
Zoltan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler is cheating you, it "remembers" the const declaration you made and takes that value to assign. Use a memcpy() call to retrieve the programmed value.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank You Bob,
Changed the read process to:
memcpy(eepromArray, flashRowDataFLASH, CY_FLASH_SIZEOF_ROW);
a = eepromArray[0];
But still read the old value after power off-on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The controller is built in a device with sensors and display, so I started to remove all unrelevante parts letting just the Flash part in the code and I find the problem. The Flash writing works fine, just its a 10 sec backcounter before saving and I have been to fast, and restarted the unit before it riched to end to save. So finally is solved, thank You so much for your time and for memcpy !
All the best !
Zoltan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are always welcome!
Bob