Store a variable in PSoC 5LP flash at a fixed address

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

cross mob
ShKr_3646021
Level 2
Level 2
First like received 10 replies posted 5 replies posted

Hi,

I have been working on a project using PSoC 5 LP. I am currently using EEPROM to store a few variables. Does any one have any idea as to how to store a variable at a particular address in flash on PSoC 5LP? We are trying to do this for a particular reason. Any pointers are appreciated.

Thanks in advance!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear ShKr-san,

1. How do I declare a fixed address? 

This is described in the Em_EEPROM Component Datasheet.

You can access the Datasheet from the Config window of Em_EEPROM component.

Click the left - bottom [Datasheet] button.

001-Em_EEPROM_Config.JPG

In the page 3 of the Datasheet is "Placing EEPROM Storage at Fixed Address" and in the steps of this chapter, there is a process of copying original linker control file "cm3gcc.ld" to "custom_cm3gcc.ld".

Just in case, I zipped and attached my "custom_cm3gcc.ld" to my original response.

And for making things sure, I attach the "Datasheet" of Em_EEPROM, too.

Best Regards,

14-Jul-2021

Motoo Tanaka

View solution in original post

0 Likes
8 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

 

I wonder if you are using EEPROM or Em_EEPROM.

If you are already using Em_EEPROM, please ignore the followings.

 

The Em_EEPROM is an EEPROM emulation using Flash area

and in the datasheet of Em_EEPROM component, there is a section

about Placing EEPROM Strorage at Fixed Address.

 

Note: As Em_EEPROM is performing ware-level management

the data is not placed from the beginning of the allocated Flash area.

 

moto

P.S. Attached is my test project of Em_EEPROM which I wrote a while ago.

0 Likes

Hi Moto,

Thank you for your response. I did look at Em_EEPROM and trying to get it to work. I have few questions about the use of Em_EEPROM. 

1. How do I declare a fixed address? 

2.  I looked at the test project you attached. I can't find custom_cm30gcc.id file in the archive. 

Thank you again for all your help.

 

0 Likes

ShKr,

It is not clear from your last post.  Are you trying to use EEPROM or Em_EEPROM?

The API calls are different for each type.

If you're using the EEPROM, there are four API calls based on the amount of data to be written.

cystatus EEPROM_WriteByte(uint8 dataByte, uint16 address);

Writes a single byte to an specific EEPROM address.  [0 to (EEPROM_SZ-1)]

cystatus EEPROM_Write(const uint8 *rowData, uint8 rowNumber);

Writes a 16-byte  array byte to an specific EEPROM row.  [0 to ((EEPROM_SZ/16) -1)].

This is a blocking function.

cystatus EEPROM_StartWrite(const uint8 *rowData, uint8 rowNumber);

Writes a 16-byte  array byte to an specific EEPROM row.  [0 to ((EEPROM_SZ/16) -1)].

This is a non-blocking function.

cystatus EEPROM_ByteWritePos(unit8 dataByte, uint8 rowNumber, uint8 byteNumber);

Writes a single byte to an specific EEPROM row [0 to ((EEPROM_SZ/16) -1)] with an offset in the row.  [0 to (16-1)]

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Len,

Sorry that wasn't clear. I would like to write a variable to flash. One of the ways I found out while reading through this forum was to use Em_EEPROM. I am trying to follow steps mentioned in the Em_EEPROM datasheet. My question now is that how do I know at what address I can put this variable at? I'd really appreciate your help. 

 

0 Likes

ShKr,

saving parameters in EEPROM is better choice, as it can withhold re-programming.

There is a custom community component which simplifies this operation

myEEPROM: component to save/recall application settings in EEPROM 

/odissey1

0 Likes

Hi odissey1,

I do not want to use EEPROM because of certain restrictions from client side. That is one of the reasons I was looking at Em_EEPROM.

0 Likes

ShKr,

I'm not sure what customer requirement would prohibit EEPROM over Em_EEPROM.

Since Em_EEPROM is FLASH based, it has more limitations than EEPROM.  For example, it has lower endurance, larger row sizes (128 bytes), writing to FLASH on the PSoC5 requires a blocking function for the entire erase and program of the entire row.  This means that a single row modification will take many milliseconds to complete before the CPU returns to the application.

EEPROM modification can be done in a non-blocking method.

I suggest you consult the PSoC5 Em_EEPROM component datasheet.

For example, here is how you declare the allocation of your FLASH-based Em_EEPROM:

const uint8 emEeprom[Em_EEPROM_1_PHYSICAL_SIZE]
__ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};

There is a section in the datasheet called "Placing EEPROM Storage at Fixed Address"  Hopefully this info addresses your need.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear ShKr-san,

1. How do I declare a fixed address? 

This is described in the Em_EEPROM Component Datasheet.

You can access the Datasheet from the Config window of Em_EEPROM component.

Click the left - bottom [Datasheet] button.

001-Em_EEPROM_Config.JPG

In the page 3 of the Datasheet is "Placing EEPROM Storage at Fixed Address" and in the steps of this chapter, there is a process of copying original linker control file "cm3gcc.ld" to "custom_cm3gcc.ld".

Just in case, I zipped and attached my "custom_cm3gcc.ld" to my original response.

And for making things sure, I attach the "Datasheet" of Em_EEPROM, too.

Best Regards,

14-Jul-2021

Motoo Tanaka

0 Likes