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

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

cross mob
Anonymous
Not applicable

 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 

   

    }

   

}

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

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

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

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

0 Likes
Anonymous
Not applicable

 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. 

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

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

0 Likes
Anonymous
Not applicable

 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. 

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

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

0 Likes
Anonymous
Not applicable

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.

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

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

0 Likes
Anonymous
Not applicable

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

0 Likes