cancel
Showing results for 
Search instead for 
Did you mean: 

Keeping Variable at Watchdog reset

Bonn.Mathias
Associate
Posted on June 06, 2018 at 15:12

Hello ST Community,

I´m using a STMS8105x6 MCU that has an appilcation running that communicates with other MCUs via UART and I2C. I also have a IWDG running, that does sometimes a reset because of communication errors.

What I want to know is, how to save a global volatile uint32_t variable that has an important value, that should not be lost at a watchdog reset.

Saving it to the EEPROM at every change is not an option. But maybe it can be stored into a backup register or the RAM somehow. Or can I prevent it from being newly initialized at startup?!

Using STVD + Cosmic Compiler.

Thank you in advance for your help.

MaBo

1 ACCEPTED SOLUTION

Accepted Solutions
Bonn.Mathias
Associate
Posted on June 06, 2018 at 16:58

Hello,

I found the solution in the following Document:

http://www.st.com/content/ccc/resource/technical/document/application_note/f8/61/9a/13/2f/f1/44/fb/CD00283293.pdf/files/CD00283293.pdf/jcr:content/translations/en.CD00283293.pdf

I hope this link is helpful to anybody with the same question.

Best regards, MaBo

View solution in original post

3 REPLIES 3
Bonn.Mathias
Associate
Posted on June 06, 2018 at 16:58

Hello,

I found the solution in the following Document:

http://www.st.com/content/ccc/resource/technical/document/application_note/f8/61/9a/13/2f/f1/44/fb/CD00283293.pdf/files/CD00283293.pdf/jcr:content/translations/en.CD00283293.pdf

I hope this link is helpful to anybody with the same question.

Best regards, MaBo

Posted on June 06, 2018 at 17:53

A structure at the end of usable RAM is a frequent method, along with shrinking the RAM size reported to the linker so it, and the C runtime, or stack, don't use or erase this space so you can decode it when you enter your main() function.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
henry.dick
Senior II
Posted on June 09, 2018 at 22:21

'

how to save a global volatile uint32_t variable that has an important value, that should not be lost at a watchdog reset.'

look in the initialization section of your compiler manual. there should be something about attributes that you can assign to variables that will prevent them from being initialized on reset. for example, iar uses '__no_init' for that. there must be something similar in cosmic.