Quantcast
Channel: Cypress Semiconductor - PSoC 4 BLE
Viewing all articles
Browse latest Browse all 726

Saving Device Name to Flash

$
0
0
Forums: 

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[i] = FLASH_DEVICE_NAME[i];
    }
    //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

 


Viewing all articles
Browse latest Browse all 726

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>