Can the function CyBle_StoreAppData store more than a page data?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I want to store data that is defined as a large array that is about 20K in flash using const.So can I use the CyBle_StoreAppData? Or should I calculate the store address and use the CySysFlashWriteRow() . Thanks!

0 Likes
1 Solution
Anonymous
Not applicable

You can use the CyBle_StoreAppData API to store data across pages, or to store small blocks of data that are less than one page in length. The internal implementation correctly updates the required sections of flash. See the following post for a simple example of that method's use:

   

http://www.cypress.com/forum/psoc-4-ble/how-store-byte-array-flash-memory

View solution in original post

0 Likes
11 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Considering that writing 20K will take a remarkable time ant there might be clock problems with some of the components I would suggest using the CyWriteFlash APIs. You probably need to freeze some of your components during the write due to internal clock changes. See "System Reference Guide".

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I just want to confirm if the  CyBle_StoreAppData has think about the cross page. I only change one or two page one time(but the data I change may be cross page). I will pass offset to CyBle_StoreAppData if it can store app data that may be cross page.

0 Likes
Anonymous
Not applicable

You can use the CyBle_StoreAppData API to store data across pages, or to store small blocks of data that are less than one page in length. The internal implementation correctly updates the required sections of flash. See the following post for a simple example of that method's use:

   

http://www.cypress.com/forum/psoc-4-ble/how-store-byte-array-flash-memory

0 Likes
Anonymous
Not applicable

And should the CyBle_StoreAppData word aligned? Can I just store one byte using it? Will it read out first to check if the write is need? Thanks!

0 Likes
Anonymous
Not applicable

That should be easy to check by reading the source code for the function; But, since you pass it a pointer to data, you can just pass an array of 1 byte length. (It should be byte aligned, and thus No. Not word aligned)

0 Likes
Anonymous
Not applicable

There is no source for the CyBle_StoreAppData function. I have this problem since I tried to test this function by writing 4 byte every 10S, and found sometime the Ble is lost and can not be found by phone. 

0 Likes
Anonymous
Not applicable

I test using a button cell, see the voltage drop on a oscilloscope when writing flash. After power on , the flash write is normal ,and I found it will take more and more time to store data into flash, after there is no voltage drop, I guess the firmware hang, and can not see the device anymore. The chip is cybl10161.

0 Likes
Anonymous
Not applicable

The function header declaration is there however, and it shows a uint8* as the argument, leading me to believe that it uses a uint8 aligned pointer of any length to write the flash data (if it was a uint16, then it would be word aligned). Note: the function should be automatically checking to make sure that the flash data is different from the data to store before writing to minimize writes to flash.

   

If the battery voltage drops too far when writing the flash, it will cause the chip to reset (or crash if the voltage doesn't return to the operating level).

   

When writing to the flash chip, it blocks interrupt handling (iirc), and it changes the clock frequency and hardware settings to write the flash effectively. This will affect the BLE radio, as the timing will be blocked by the interrupts being turned off, and the clock timings will be changed to write the flash to the chip. My recommendation is to change your code to only write the flash data when not actively using the BLE radio.

0 Likes
Anonymous
Not applicable

Since the firmware is hanging, either the BLE stack is crashing/locking up, or your code that is running is being interrupted by the flash writing somehow.

0 Likes
Anonymous
Not applicable

Thanks,e.pratt.

   

Now I just get confused why it takes more and more time to writing to flash. I think the 10S interval is enough for the flash to take rest.

   

The code I use:

   

const uint8 testFlash[128] CYBLE_FLASH_ROW_ALIGNED;
const uint8 testFlash1[128] CYBLE_FLASH_ROW_ALIGNED;

   

testFlashCnt++;

   

if(testFlashCnt % 10 == 0)

   

{

   

writeToggle ^= 1;

   

CyBle_ExitLPM();

   

//CyBle_StoreAppData((uint8*)&testFlashCnt,&testFlash[testFlashCnt],4,1);

   

do { /* write segment of configuration structure from RAM into flash */

   

result = CyBle_StoreAppData(

   

(uint8*)&testFlashCnt, /* uint8 pointer to source data */

   

writeToggle?testFlash:testFlash1, /* uint8 pointer to const destination */

   

4, /* number of bytes to write */

   

0); /* don't force write, but loop will keep retrying */ }

   

while (result != CYBLE_ERROR_OK); }

0 Likes
Anonymous
Not applicable

Have you tested if the time delay for flash writing occurs when the board is powered off a voltage power supply? (a consistent power source)

   

It might be that the dropping voltage from the battery is causing the flash to take longer to write due to internal RLC time circuits.

   

If you want to know how long the flash chip itself is taking to write, then you could try doing some sort of debug/timing scheme on an external pin and an oscilloscope to measure the time from starting the flash chip until the write has finished.

   

I've run into some cases where if the Flash data doesn't change, then it never sets the cyble flash write data pending flag, and thus the cyble_storeappdata() function doesn't get called the first time, but looking at your code above that doesn't look like the case.

0 Likes