cwd wd+ wd-
cwd ( ---)
Specific Flash Forth
Clear the WatchDog counter.
The word cwd
is called in all loops which risk
To block. Typical case: waiting for a character or a signal.
Some words also reset the watchdog: emit key pause
.
wd+ ( n -- )
Specific Flash Forth
Start watchdog timer, n must be less than 8.
Possible values:
value | WDP2 | WDP1 | WDP0 | time out (ms) |
---|---|---|---|---|
0 | 0 | 0 | 0 | 16 |
1 | 0 | 0 | 1 | 32 |
2 | 0 | 1 | 0 | 64 |
3 | 0 | 1 | 1 | 125 |
4 | 1 | 0 | 0 | 250 |
5 | 1 | 0 | 1 | 500 |
6 | 1 | 1 | 0 | 1000 |
7 | 1 | 1 | 1 | 2000 |
The value of n indicates the delay between the execution of cwd
and the
restarting FlashForth:
: infinite ( ---) begin again ; cwd 7 wd+ infinite \ normally, FlashForth will restar after 2 seconds
WARNING: if your loop sends characters, the watchdog will be inoperative, because
emit
executes a cwd in its code.
Likewise, entering a character at the keyboard also performs a cwd.
wd- ( -- )
Specific Flash Forth
Stop the watchdog. Example:
: tempKey ( ---) 7 wd+ begin key? dup if drop key emit wd- exit then until ;
Execution off tempKey
:
\ press 'h' key on keyboard before 2 secnds delay tempKey h ok<#,ram> \ press no key, restart after 2 seconds tempKey W FlashForth 5 ATmega328 13.01.2019
If a word is stored in the turnkey
vector, it will be executed
on restart:
: test ." -> restart" cr ; ' test is turnkey
Now we execute tempKey
without pressing a key, we have:
tempKey W FlashForth 5 ATmega328 13.01.2019 ESC -> restart