Hallo,
ich versuche ein paar Daten (wenige int) über einen Neustart eines Atmega8 zu retten (speziell bei Neustart durch Watchdog ).
Programmiert wird mit ICCAVR, der als ordentlicher C-Compiler natürlich den gesamten RAM am Anfang löscht. Dort geht es also nicht.
Im Netz fand ich den Tip, die Daten an das Ende des Stack zu legen:
########################################### I'm wondering if anyone has some good idea on debugging a sporadic watchdog reset I get (about once a day)?
I thought I could set a variable to different values in different parts of the program and then at reboot store it in another, but if I understod correctly even unitialized variables gets initialized to 0, so that wouldn't work.
EEPROM is to slow for storing it in.
From richard-lists at imagecraft.com Wed Jul 20 23:23:32 2005 From: richard-lists at imagecraft.com (Richard) Date: Wed Jul 20 23:24:25 2005 Subject: [Icc-avr] Debugging watchdog reset In-Reply-To: References: Message-ID:
First, see the Help on "Stacks" and Stack Checking Functions, it explains why you can't use &_bss_end+1. Anyway, you can do something like this:
extern char _bss_end; char *p = &_bss_end+2;
.... *p = ...;
As long as you are not using the heap or that the stacks are running into that part of SRAM, then you can use the space after bss_end.
########################################### Etwas besseres fiel mir bisher nicht ein, ich habe das nun etwas abgewandelt:
extern int _bss_end; int *a = &_bss_end+3; int *b = &_bss_end+5;
Mit den Variablen kann ich arbeiten, a und b sind nach Neustart aber immer wieder 0. Ich kann aber auch in den Bibliotheken nichts finden, wo der ICCAVR den Stack mit 0 beschreibt.
Hat irgendwer eine Idee oder einen besseren Lösungsvorschlag für das eigentliche Problem? Nutzung des EEPROM ist aufgrund der beschränkten Zyklen leider keine Alternative, zusätzliche Hardware wollte ich eigentlich möglichst vermeiden.
Lutz