Read/Write Access to Flash Memory

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

cross mob
LaBr_292471
Level 1
Level 1

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.

   

Lane

0 Likes
4 Replies
ErBU_1372276
Level 2
Level 2
First like received

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).

   

Eric

0 Likes

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?

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

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.

   

 

   

Bob

0 Likes
LaBr_292471
Level 1
Level 1

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?

0 Likes