CySoftwareReset PSoC3 and EEPROM: how it works?

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

cross mob
WolfgangCS
Level 3
Level 3
25 replies posted 50 sign-ins First solution authored

Hello,

I would be interested in understanding how the CySoftwareReset function works, particularly when using a PSoC3: what things are reset? Is the EEPROM memory also reset or deleted? If so, how would it be possible to erase/restore the EEPROM via the firmware?
Thank you all

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

a_deseta.

Hi.  Welcome to the PSoC family of MCUs.

"... what things are reset? Is the EEPROM memory also reset or deleted?"

CySoftwareReset() sets the RESET bit in a RESET_CR2 register.  

When this occurs, the CPU program counter is forced to run at the RESET interrupt vector.  In other words, the CPU begins to run SW at the same place when coming out of a power-on (HW) reset.

A number of PSoC resources get reset.  This is detailed in PSoC3 Registers Technical Reference Manual.  Here's a list:

  • The manual details all the registers and its reset default values.  Note: Not all registers get reset.
  • The CPU temporary local registers such as stack pointer (SP).
  • The UDBs used in the project are cleared.  (These are set via register configuration)
  • All fixed non-memory resources such as timers, HW I2C, ADCs, DACs, clock dividers/configuration, etc are set to default values.

Here's is a list of fixed resources that are NOT reset (or cleared):

  • FLASH
  • SRAM
  • EEPROM (I hope this answers your one question)

"... how would it be possible to erase/restore the EEPROM via the firmware?"

There are EEPROM API calls that allow for EEPROM modifications.  This is NOT performed at reset and almost always should not be.  The intent of EEPROM is that the content survives RESET.  This allows applications to set the EEPROM (for example configuration data) and then after a reset, the configuration can be read from EEPROM and returned to operation.

I have used EEPROM to store ADC calibration values I obtain during a calibration event when it is first manufactured.  On a RESET, the last set calibration values are used when the ADC performs a conversion.

Here are the public EEPROM API calls:

  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Init()
  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Read()
  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Write()
  • Cy_Em_EEPROM_Erase()
  • Cy_Em_EEPROM_NumWrites()

Consult the EEPROM component datasheet to help you understand how to use this resource.

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

View solution in original post

3 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

a_deseta.

Hi.  Welcome to the PSoC family of MCUs.

"... what things are reset? Is the EEPROM memory also reset or deleted?"

CySoftwareReset() sets the RESET bit in a RESET_CR2 register.  

When this occurs, the CPU program counter is forced to run at the RESET interrupt vector.  In other words, the CPU begins to run SW at the same place when coming out of a power-on (HW) reset.

A number of PSoC resources get reset.  This is detailed in PSoC3 Registers Technical Reference Manual.  Here's a list:

  • The manual details all the registers and its reset default values.  Note: Not all registers get reset.
  • The CPU temporary local registers such as stack pointer (SP).
  • The UDBs used in the project are cleared.  (These are set via register configuration)
  • All fixed non-memory resources such as timers, HW I2C, ADCs, DACs, clock dividers/configuration, etc are set to default values.

Here's is a list of fixed resources that are NOT reset (or cleared):

  • FLASH
  • SRAM
  • EEPROM (I hope this answers your one question)

"... how would it be possible to erase/restore the EEPROM via the firmware?"

There are EEPROM API calls that allow for EEPROM modifications.  This is NOT performed at reset and almost always should not be.  The intent of EEPROM is that the content survives RESET.  This allows applications to set the EEPROM (for example configuration data) and then after a reset, the configuration can be read from EEPROM and returned to operation.

I have used EEPROM to store ADC calibration values I obtain during a calibration event when it is first manufactured.  On a RESET, the last set calibration values are used when the ADC performs a conversion.

Here are the public EEPROM API calls:

  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Init()
  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Read()
  • cy_en_em_eeprom_status_t Cy_Em_EEPROM_Write()
  • Cy_Em_EEPROM_Erase()
  • Cy_Em_EEPROM_NumWrites()

Consult the EEPROM component datasheet to help you understand how to use this resource.

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

Dear Len,

Thank you very much for the answer.

Some things are now clearer to me. As far as deleting the EEPROM is concerned, I understand that the EEPROM API and the Cy_Em_EEPROM_Erase() function can be used to delete the contents of the memory. Can this also be done using the PSoC Creator software?
Thanks

 

0 Likes

a_deseta,

 Cy_Em_EEPROM_Erase() allows for erasure of EEPROM at the sector level or the entire contents at run-time (firmware).

If you are looking to "preset" the EEPROM at design-time there is a in PSoC Creator using the Design-Wide Resource editor called "EEPROM"

Len_CONSULTRON_0-1636054955673.png

Set "Include EEPROM image in Hex file" then modify the EEPROM image shown in the editor to the value(s) you want.  This will include the preset value(s) you want when you first program the PSoC IC.

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