Home > Electronics Tutorials > Microcontroller Tutorials and Projects > DALLAS DS80C320 Tutorial > Dallas 80C320 - Watchdog System Resets

Microcontroller Tutorials

Dallas 80C320 / DS80C320
Watchdog System Resets

Watchdog System Resets

If the watchdog timer is allowed to run out and no action is taken to reset the timer in the Watchdog Interrupt, the watchdog will automatically reset the system.

A reset caused by the watchdog is like any other reset with one exception: The WTRF bit (WDCON.2) will be set. That is to say, if WTRF is clear it means the system is booting due to some other non-watchdog related reason. If the bit is set, the boot is due to the watchdog.

You can use this information in your application to execute special code in the event a watchdog reset occurs. Take the following psuedo-code, for example:

    ORG 0000h
    JNB WTRF,NORMAL
    PRINT "The system locked up and was rebooted by the watchdog."
    PRINT "Skipping normal device initialization."
    LJMP MAIN
    NORMAL: LCALL INITIALIZE_LCD
    LCALL INITIALIZE_XRAM_VARIABLES
    MAIN: (continue normal program execution)
     
Note that if you put all your variables in Extended RAM, a watchdog reset will not erase them. Observe in the above psuedo-code that if the system is booting due to a watchdog reset, it skips the LCD and variable initialization routines. Thus, when program execution resumes at MAIN, all variables in XRAM will still be intact.

Programming Tip: While it is true that the 80320 will not clear XRAM on a watchdog reset, most compilers will. That is to say, the 80320 itself will not do anything to erase XRAM. However, the watchdog reset will effectively provoke a system reset. Few, if any, third party development packages check the status of the WTRF flag on startup. Thus, the system will reset and XRAM will remain intact: However, your 'C' compiler's startup code will most likely then proceed to initialize all your variables, including those stored in XRAM. If you are using a high-level language (such as 'C', Pascal, BASIC, etc.) you will most likely need to investigate how you can instruct your compiler NOT to initialize variables automatically.

However, if you are writing your program in assembler you'll have no problem: the values you've left in XRAM will be left completely intact since your assembler will only assemble the code you write--it won't include built-in variable initialization code.

 Click here for >>>> Dallas 80C320 - Chapter 4 (Power Failure Functions)

Note: To report broken links or to submit your projects, tutorials please email to Webmaster

Discover

     more......