That function is already implemented, and it can be used to store data in non-SFLASH areas on the device. You just need to supply a flash-stored constant location as the destination pointer. Check out the following discussion forum topic:
Note that this function as described in the linked topic will write data to the normal (overwritable) flash area on the device. This is not the same as supervisory flash, which persists across SWD re-flash cycles.
Ah, no need to write my own then. Thanks!
I'm assuming I can't use the Cyble_AppStoreData() function to write to the supervisory flash location then?
Ideally, I'm looking to write debug values into the sFlash for debugging devices from the field if/when they come back with issues. Since the regular flash will be set to unreadable for code protection, that would make it hard to read the flash once it is programmed I'm assuming.
Thanks for the link to the other topic post :), it was very helpful for understanding what is going on.
That is correct; the CyBle_StoreAppData() method will not work for SFLASH. Writing to the SFLASH area requires specific register operations instead. The simplest reference for that is actually the 100 Days project that you linked to in your original post. The PDF for that project (also on the GitHub repo) describes at a high level how it works, and you can find the specific code that does the writing in the WriteUserSFlash.c file:
I'm having trouble getting the example SFlash code working; Is there a reason for the write and read functions using uint8 and uint32 pointers respectively? Is it merely a matter of preference/use that the two pointers are different sizes (besides the write function requiring uint32 to write obviously)?
Is there a reason to the syntax WriteUserSFlashRow(rowIndex, &data); instead of WriteUserSFlashRow(rowIndex, data);?
Is it allowable to read the SFlash data as uint32() values instead of uint8 values?
1 of 1 people found this helpful
In our recent versions of the creator, we have our own functions to write to the SFlash. The project in the 100 days list uses a custom function as it is an old project.
Please use this project in the PSoC Creator example project for your reference for using the SFlash:
C:\Program Files (x86)\Cypress\PSoC Creator\4.0\PSoC Creator\examples\sampleprojects\SFlash_Example
- Madhu Sudhan
Thanks Madhu; It indeed looks newer than the 100 days project :)
Hi, I have tried out the new SFlash example. I am unable to get the LED error light to blink. I have also followed the project description to comment out the code "returnValue = CySysSFlashWriteUserRow(CY_TEST_SFLASH_ROW, rowPattern)" but to no avail. Did I do something wrong?
Did you correctly match up the pins for the LEDs to the pins for your specific device/module you are using?
If the SFlash data was already written (on a previous program run for example), then the data written to SFlash will still be in SFlash, and thus there will be no changes between what is stored in the SFlash and what you are looking for in the code.
Try changing the data pattern instead of commenting out the line to see if it writes a new data line to the SFlash;
Also, if you have a debugger, you can break on the comparison when reading back the SFlash to see what it returns.