You are here

PSoC 3 Flash memory | Cypress Semiconductor

PSoC 3 Flash memory

Summary: 6 Replies, Latest post by danaaknight on 12 Dec 2014 04:15 AM PST
Verified Answers: 2
Last post
Log in to post new comments.
atenito's picture
5 posts


I need to write in the flash memory some things but I don´t know how to do it. 

I found that with this three functions(CyWriteRowFull(),CyWriteRowData(),CyWriteRowConfig() ) it´s posible to do it, but I haven´t found any example of it and I don´t know how to use them. Has anyone have a example?

And another question, imagine that I wrote in the flash, how can I read what is write in the flash?

Thanks and regards,


user_1377889's picture
9241 posts

The PSoC3 has got an EEProm which you could use instead of flash. Additionally there is an emeeprom (emulated eeprom) component that stores data in flash. For both components you'll find example projects (right click on component).

Easiest access is using emulated eeprom. Define a structure that describes your data and initialize it in flash.

const struct YourStruct = { initialization Data };    //  Will be in flash




atenito's picture
5 posts

Hi Bob,

I know that PSoC 3 has also an EEProm but I have more than 2KB information to store. This is the reason why I want to use the flash memory.

I´m going to try with the emeeprom component. 





user_14586677's picture
7646 posts

Some additional considerations -


1) EEPROM allows 1M erase/program cycles, whereas emulated EEPROM in FLASH is speced

at 100K erase/program cycles.


2) Access to EEPROM or FLASH typically done with a pointer. You will find a number of

defines in CyFlash.h that amongst other things give you the base address. You use that

with offsets to retieve your data.


#define CY_FLASH_BASE               (CYDEV_FLASH_BASE)
#define CY_FLASH_SIZE               (CYDEV_FLS_SIZE)

#define CY_EEPROM_BASE              (CYDEV_EE_BASE)
#define CY_EEPROM_SIZE              (CYDEV_EE_SIZE)


Regards, Dana.

atenito's picture
5 posts

It´s what I need, so Thanks.


But I have another two questions,


In the example of the emulated EEprom the structure where we write is: "static const uint8 CYCODE eepromArray[]".


First question: Do I need to reserve the space which I´m going to use with this structure? Or I can only reserve like in the example 14 bytes and after this I can write more than 14? I don´t know if I have explained correctly. 


Second question: When we write in the flash we use this function: Em_EEPROM_Write(). When we call to this function, does it write only the bytes we put? O it writes all the row(256 bytes)?

Sorry if I have explained badly. 



user_1377889's picture
9241 posts

You always have to reserve (at least) the amount of bytes you use. Behind your struct in flash will be some code which you probably do not want to overwrite. ;-)

Em_eepromWrite() needs the starting address and the number of bytes to write, so you may even write parts of your struct if wanted.



user_14586677's picture
7646 posts

FLASH is always written on a ROW basis. However for the API it invokes

a buffer to read, modify, then write back a complete ROW even though you

are only specifiying a partial ROW. This suttle distinction means that erase/write

cycles apply to the whole ROW, not just the bytes written. Hence whole ROW

lifetime is affected, not just the lifetime of the bytes used. Also notice in last

paragraph above need to use "volatile" on varables stored in FLASH.


Regards, Dana.


Functional Description
The Emulated EEPROM component is purely a firmware abstraction of the flash memory. It
consumes no other resources.
The Emulated EEPROM component does not correspond to a single instance of a virtual
EEPROM. Instead, it provides a write function to safely interact with variables and arrays defined
in flash. The Em_EEPROM_Write() function is a simple way to modify user variables, defined in
flash, so that variable values will be saved between power cycles.

Flash memory is readable by byte, like other memory spaces. Read access to the emulated
EEPROM is achieved by directly reading the underlying flash variable or array.

The Em_EEPROM_Write() API handles writes that are not aligned to the beginning/end of a
flash row. Data that resides in the same flash row as the location of the emulated EEPROM data
is not affected by writes to the emulated EEPROM data. This is accomplished by first reading the
contents of a shared row into a buffer on the stack, modifying the data targeted by the Write(),
and writing the buffer back to flash.

In designs that use the ECC memory for data storage (on devices that have ECC memory), the
ECC memory is not affected by writes to the emulated EEPROM.

In order to force the compiler to locate data in Flash, variables/arrays should be declared as
static const (CYCODE for PSoC 3)” and initialized with some value at the same time. Reads
from Flash are recommended to be done using “(volatile)” type qualifier to prevent the compiler
from optimizing reads from static variables. For details on component usage please refer to
Emulated EEPROM example project.

Log in to post new comments.