- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to save, and read back, the device name from flash without success. I am using this code:
/* Flash Config */
#define FLASH_SIZE 128
/* Flash constants */
#define FLASH_ROW_SIZE_BYTES 128
#define FLASH_ALIGNED __attribute__ ((aligned (FLASH_ROW_SIZE_BYTES)))
static const char FLASH_DEVICE_NAME[FLASH_SIZE] = {0}; // Flash space for device name
char device_name[FLASH_SIZE]; // User input device name
/* Flash data write constants */
#define FLASH_DATA_BASE_ADDRESS_BYTE (uint32) (&FLASH_DEVICE_NAME)
#define FLASH_DATA_BASE_ADDRESS_ROW FLASH_DATA_BASE_ADDRESS_BYTE / FLASH_ROW_SIZE_BYTES
void ReadNameInFlash()
{
uint8 i;
// Read device from Flash
for (i = 0; i < FLASH_SIZE; i++) {
device_name = FLASH_DEVICE_NAME;
}
//CyBle_GapSetLocalName(device_name);
}
void SaveNameInFlash(const uint8 device_name[])
{
CySysFlashSetWaitCycles(48);
CySysFlashWriteRow(FLASH_DATA_BASE_ADDRESS_ROW, device_name);
// CyBle_GapSetLocalName((const char *)device_name);
}
I have commented out the CyBLE calls as the BLE stack is not initialized at this point. The call to CySysFlashWriteRow results in a return code of CY_SYS_FLASH_SUCCESS.
The read of flash returns all zeros....
Thanks for the help.
Rich
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I solved this by bailing on writing to flash. I now store the device name to SFLASH, row 1.
Rich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I solved this by bailing on writing to flash. I now store the device name to SFLASH, row 1.
Rich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rich,
SFLASH will work, but there is another API that is suitable for this purpose and may be preferable under some circumstances (i.e. SFLASH is retained across SWD reflashing, while this other method is not). The API is CyBle_StoreAppData(). You can see some discussion and example snippets in this forum topic: