AVR8 watchdog (reset and interrupt) atmega328p

I wanted to use the 128 kHz watchdog oscillator as an additional
timer.  I saw that AVR8 watchdog timer and reset was addressed on the
mailing list in late 2013 using assembler.frt 

In the source tree there is an assembler word -wdt (no-wdt.asm), which
writes $0 to WDTCSR (using the prescribed sequence), but I couldn't
find something like a "+wdt". This may well be because I did not look
hard enough, so my apologies if it was there all along.

Using -wdt as a template I have written four companion assembler words
and a slightly modified version of -wdt (to leave the existing
prescaler and WDIE bit unmodified).

+wdt ( -- )        set WDE (System Reset Mode)   
-wdt ( -- )        unset WDE (leaves prescaler)  
+wdi ( -- )        set WDIE (Interrupt mode)     
-wdi ( -- )        unset WDIE (leaves prescaler) 
wd.delay! ( n -- ) set prescaler , unset WDE and unset WDIE 

where n is the 4 bits representing the prescaler. 

With the 4 cycle write requirement dealt with by (optional at build
time) built in words the 128kHz timer is accessible and adds a
lot. Could similar words be added to AmForth or is this too
device/application specific?

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Amforth-devel mailing list for http://amforth.sf.net/

Reply via email to