cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

New Contributor

What APIs should I use to store non-volatile data?

I am using cyw43907 and the manual says it supports External Flash Memory.

I wonder if I should use wiced_sflash_write to store the data, or whether I can save it using wiced_dct_write.

0 Likes
Reply
1 Solution
Moderator
Moderator

You can use wiced_dct_write() to store data during runtime in DCT section of flash. The string_var in the example is modified during runtime. The dct_read_write_app_dct_t struct in the example is user defined. Similarly you can have your own struct or you can simply store other data types in DCT dynamically. Using API to directly write to SFlash is not recommended because the SFlash has a well defined memory layout and if you write data into a dedicated section (such as bootloader), you may risk corrupting that section.

View solution in original post

5 Replies
Moderator
Moderator

You can use DCT app section so that the data persists across power cycles. Please refer to snip.dct_read_write to check how the App section is modified.

0 Likes
Reply
New Contributor

Yes, I saw the snip.dct_read_write project.

But the example seems to have to use dct predefined(like my_app_dct_t structure), right?

What I want to do is dynamically save and store data in flash.

Can I use sflash_read/write API?

0 Likes
Reply
Moderator
Moderator

You can use wiced_dct_write() to store data during runtime in DCT section of flash. The string_var in the example is modified during runtime. The dct_read_write_app_dct_t struct in the example is user defined. Similarly you can have your own struct or you can simply store other data types in DCT dynamically. Using API to directly write to SFlash is not recommended because the SFlash has a well defined memory layout and if you write data into a dedicated section (such as bootloader), you may risk corrupting that section.

View solution in original post

New Contributor

Oh, I see. Thank you for answer

If so, which API should I use if I want to delete all the data in the flash's DCT_APP_SECTION?

There is only read/write in the dct API.

0 Likes
Reply
Moderator
Moderator

You can set the value of each member of the structure to 0 and write this in DCT. This should be done between wiced_dct_read_lock() and wiced_dct_read_unlock().

0 Likes
Reply