Retain Variable in Ram through Reset

Processor is being reset by an external device. (will be fixed in a later version of the hardware)
For now the easiest fix for me would be to keep a check sum with the variable in RAM.

startup
check variable with checksum
if it is correct use the variable
if not initialize to 0
while()
{
every second update variable and checksum
}