#include #define DEBUGLOCAL #define TAKTMHZ 12 #define WATCHD_1100MS 0x80 #define WATCHD_65MS 0 #define WATCHD_512US 0x7F #define WATCHD_START(zeitk) WDTREL=(zeitk);SWDT=1; #define WATCHD_RESET WDT=1;SWDT=1; #define WATCHD_CLEAR SWDT=0 #define WATCHD_STATUS_ON (IP0&0x40) #define WATCHD_STATUS_SET IP0|=0x40; #define WATCHD_STATUS_CLR IP0&=~0x40; void debuglocal(void) { if (WATCHD_STATUS_ON) { /* Hier landet man, wenn eine Reset durch den Watchdog stattgefunden hat */ WATCHD_STATUS_CLR; /* Testen des Verhaltens bei regelmäßigem Rücksetzen */ while (1) { WATCHD_RESET; } } else /* Watchdog war noch nicht aktiviert */ { /* Watchdog wird mit kürzestmöglicher Periode gestartet */ /* Im Simulator wird überprüft, ob ein RESET nach 512 us erfolgt */ WATCHD_START(WATCHD_512US); while(1) { /* es erfolgt kein Rücksetzen des Watchdog */ } } } #ifdef DEBUGLOCAL void main(void) { debuglocal(); } #endif DEBUGLOCAL