Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > SRAM memory is deleted when a software or watchdog reset occurs?

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



SRAM memory is deleted when a software or watchdog reset occurs?
Moderator:
ANCY

Post Reply
Follow this topic



SRAM memory is deleted when a software or watchdog reset occurs?

adrian_ posted on 07 Apr 2012 4:53 AM PST
Top Contributor
26 Forum Posts

 Hello. Is SRAM memory deleted if software or watchdog reset occurs? I know that RAM memory is volatyle, and i am using PSoC5.

Here is the code i would use for testing if SRAM is deleted or not if reset occurs. I am wondering if it is ok. 

 

#include <device.h>

 

void main()

{

unsigned char *P = (unsigned char*)0x20000000;

unsigned char cnt = 0;

if(*P != 0xAA)

{

*P = 0xAA;

Pin1_Write(1); //led1 is on if SRAM is erased 

Pin2_Write(0);

}

else

{

Pin1_Write(0);

Pin2_Write(1); //led2 is on if SRAM is not erased

}

    for(;;)

    {

        cnt++;

CyDelay(1000);

if(cnt == 16) 

CY_SET_REG8(RESET_CR2, 1); //software reset 

    }

}

 

 




Re: SRAM memory is deleted when a software or watchdog reset occurs?

Bob Marlowe posted on 07 Apr 2012 07:07 AM PST
Top Contributor
1768 Forum Posts

As far as I understand "Reset" the code for boot is executed AND the initialization for your C-Program is executed as well. This will bring all your variables in Ram (reardless of the "S") to a known state: Initialized.

Only values stored (rather:programmed) into flash are kept across resetings of the PSoC

 

Bob



Re: SRAM memory is deleted when a software or watchdog reset occurs?

Bob Marlowe posted on 07 Apr 2012 08:59 AM PST
Top Contributor
1768 Forum Posts

I just found this http://www.cypress.com/?rID=40391 to preserve memory when watchdog reset occurs for PSoC 1.

Just for the completeness: The "S" in SRAM stands for "Static" but this has nothing to do with keeping the data across resets. It is ment in opposite to "Dynamic" or DRAM which must be refreshed from time to time (a few ms) to keep the data.

 

There is a flag you may read to see if is was a watchdog reset or an external reset. Have a look here http://www.cypress.com/?app=forum&id=2233&rID=56423 

Bob



Re: SRAM memory is deleted when a software or watchdog reset occurs?

adrian_ posted on 08 Apr 2012 01:08 PM PST
Top Contributor
26 Forum Posts

 That is what i am looking for. But i need it for PSoC5, i searched the site for simillar article (for PSoC5) and looked in the TRM but i didn't found anything. 



Re: SRAM memory is deleted when a software or watchdog reset occurs?

Bob Marlowe posted on 08 Apr 2012 01:51 PM PST
Top Contributor
1768 Forum Posts

One of the problems is, that the CPU starts anew at reset just like at power-on. This implies all initialization is done anew as well, hardware and software. This behaveour will spoil the memory in a PSoC1 as well, exept when programming in assembly, then there might be a chance to preserve some memory locations.

This is the point where flash memory drops in: you can normally reduce the absolutely required data needed after a reset to a very small amount (a handfull of floats, some ints and a couple of state-variables). When this area is programmed into flash you can access it even after a power-loss. You'll need a little trick to see whether the flash is programmed already or not, but that's all. To concider is a power-loss when programming the flash which can be overcome with some capacity on the power-supply.

Bob



Re: SRAM memory is deleted when a software or watchdog reset occurs?

adrian_ posted on 09 Apr 2012 01:13 AM PST
Top Contributor
26 Forum Posts

 I don't understand, i might have missed something.

After the code is loaded in flash, and the program is running, is it possible to save variables (stored in DRAM or SRAM, whathever), in flash memory? Let's say that this can be done.

But you don't know when a watchdog reset would occur. In this case, you should regularly save the variables you need, in the flash memory (which, i suppose, if it can be done, it would make the program much slower).

I could use the EEPROM (512bytes are more than enough for me). But the problem is that, it have 1.000.000 read/write cycles. So, let's say that i save the variables i need, in EEPROM, every minute. That means that the EEPROM can't be used after ~694 days (that's 2 years), which is low.

The best solution is preserving RAM locations, so after recovering from reset (watchdog reset) useful variables won't get lost. But i still didn't found how can i do this (on PSoC5 or PSoC3).  Thanks for your replys, they are helpful. 



Re: SRAM memory is deleted when a software or watchdog reset occurs?

Bob Marlowe posted on 09 Apr 2012 02:21 AM PST
Top Contributor
1768 Forum Posts

I tried to point out in a polite way: you cannot do that! A watchdog reset is like an emergency brake, when the train has stopped you'll probably not sitting on your original place (broad smile). A watchdog reset shows that your program (or your hardware) visited electronic nirwana or else the WD interrupt would not have occured. It is like the Reset-button on your PC: when you press it all the current RAM - information are NOT(!!!) lost, but they are assumed to be useless and overwritten.

I thinki, you are trying something special, if you share a bit more information with us, we might help you a bit further.

What are you using the WD for, what will your application perform.

 

Bob

 



Re: SRAM memory is deleted when a software or watchdog reset occurs?

adrian_ posted on 09 Apr 2012 03:37 AM PST
Top Contributor
26 Forum Posts

I know what a watchdog timer do. 

I am interested in finding-out if there is some way to recover from a watchdog reset, without loss of data.

I don't have a specific application in mind. Certain is that the applications that i will develop on PSoC5/PSoC3 will be used in industrial environment. And in such environment there is a high probability that the processor might go in a "electronic nirwana" and that's why i need to use a watchdog.

You showed me that article for PSoC1, with preserving RAM. I am interested if there is a similar article for PSoC3/5. I think i described well enough what i am trying to do.

Another solution for my problem would be to periodically flush a buffer (stored in RAM) to an external SD card, so if a watchdog reset was detected, the variables could be restored, and the process can be continued, not started from the beggining. But this solution is to expensive.

  



Re: SRAM memory is deleted when a software or watchdog reset occurs?

Bob Marlowe posted on 09 Apr 2012 04:01 AM PST
Top Contributor
1768 Forum Posts

Give it a try:

Declare a memory-area at a specific fixed address of 256Bytes for instance. (Not at the beginning and not at the end of RAM) 

Check for a known pattern in the area, signal the result with a LED

If result was FALSE, write known pattern into the area.

stop Program (infinite Loop)

Press reset or let WD happen

 

You will see that there are memory areas where the contents will not be destroyed.

The problem might be that depending on your program's memory usage the 256-byte Area MIGHT become overwritten.

But it's cheaper than external SRAM.

 

Bob



Re: SRAM memory is deleted when a software or watchdog reset occurs?

adrian_ posted on 10 Apr 2012 12:25 AM PST
Top Contributor
26 Forum Posts

 Using the debugger is way easier to see what happens in memory. Thanks for the triks :)






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20