I am using the PSoC Creator and wondering if there is a way to read/write to a small section of the FLASH memory. I want to reserve say something like 128 bytes at the end of the flash memory for me to store a serial number and other application configuration information. Is that possible? I want the firmware to be able to read/write the flash.
That's possible, you can use cyflash.c function. But you should modify the linker script to place your variables at a specific location (AN 89610 can help).
Thanks for the pointer to cyflash.c. In there I see some functions to write to the SysFlashRows and SysFlashUserRows, but I don't see anything about reading these rows. Is the flash memory mapped? The comments say to see the TRM, but I haven't seen anything related to the flash memory in the the PRoC BLE datasheets. I'd really like to see a detailed explanation of the flash memory. For example, does code execute directly from flash or get loaded into RAM?
There are no APIs needed to read from flash. Easiest is to use a pointer to your data that gets filled with the (calculated) address. Just as a datafield residing in the program memory area, there is no special code needed to access that data.
I found the flash_example code and that is exactly what I need as it shows how to read/write from the flash memory, and I can see from the linker file that the flash memory is memory mapped to 0x0000. Now all I need to know is what is available to write to. Am I correct that the program code is in flash? Is anything else? How can I tell what is free to write to?