Watchdogreset in Flowcode
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
You can add a C icon with the text "clr_wdt();" in it to clear the watchdog timer.
The problem is that any delay routines (e.g. the delay icon) will not reset the watchdog timer. You would need to create a long-ish delay this in another way (e.g. by calling multiple small delays with the "clr_wdt();" statement between them).
The problem is that any delay routines (e.g. the delay icon) will not reset the watchdog timer. You would need to create a long-ish delay this in another way (e.g. by calling multiple small delays with the "clr_wdt();" statement between them).
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Hello Mark,
Unfortunately it's not that easy because the 'C' delay functions do not reset the watchdog timer - so as soon as you add a 1 second delay, the watchdog timer will be triggered.
There may be a way around this, by modifying the delays code so that a shorted delay is called multiple times within a loop that also resets the watchdog timer. I will look into how easy this would be to do.
Unfortunately it's not that easy because the 'C' delay functions do not reset the watchdog timer - so as soon as you add a 1 second delay, the watchdog timer will be triggered.
There may be a way around this, by modifying the delays code so that a shorted delay is called multiple times within a loop that also resets the watchdog timer. I will look into how easy this would be to do.
-
- Posts: 209
- Joined: Thu Oct 19, 2006 11:46 am
- Location: Bakewell, UK
- Has thanked: 20 times
- Been thanked: 16 times
Hi Steve,
I am not sure that you can stop misapplication of the WDT. After all, if the prescaler is used with Timer0 or the prescaler timeout is short, even though assigned to the WDT, the same problems will occur with even shorter delays than 1s (or even with the ASC at low clock speeds).
The WDT functionality is present anyway and accessible via the config dialog. I would suggest making sure that when WDT is selected in the Config dialog that an 'only if you know what you are doing' dialog pops up, or the option is coloured red etc. This would in any case save the perennial forum post from newbies not being able to get their programs working (and those who just never get as far as the forum and give up?).
On the other hand, chips like the 16F88X have WDT timeouts of very many seconds (if you want it).
The CLRWDT icon can be simply that command, it is just that I only want to use 'C code specials' in Flowcode when I have to and not for trivia like CLRWDT or for that matter SLEEP. If you ever do contemplate adding such a flowsymbol then incorporating in it an automatic calculation/estimate of WDT timeout period (from prescaler assignment and nominal WDT clock speed) would give it added value.
Regards
Mark
ps the SLEEP icon would need a check box to optionally add a NOP after the Assembler sleep command (see data sheet).
pps In any case, these two suggestions give you just about the easiest 'win' in adding useful functionality to Flowcode that I can imagine and would be more widely usable than, say I2C etc.?
I am not sure that you can stop misapplication of the WDT. After all, if the prescaler is used with Timer0 or the prescaler timeout is short, even though assigned to the WDT, the same problems will occur with even shorter delays than 1s (or even with the ASC at low clock speeds).
The WDT functionality is present anyway and accessible via the config dialog. I would suggest making sure that when WDT is selected in the Config dialog that an 'only if you know what you are doing' dialog pops up, or the option is coloured red etc. This would in any case save the perennial forum post from newbies not being able to get their programs working (and those who just never get as far as the forum and give up?).
On the other hand, chips like the 16F88X have WDT timeouts of very many seconds (if you want it).
The CLRWDT icon can be simply that command, it is just that I only want to use 'C code specials' in Flowcode when I have to and not for trivia like CLRWDT or for that matter SLEEP. If you ever do contemplate adding such a flowsymbol then incorporating in it an automatic calculation/estimate of WDT timeout period (from prescaler assignment and nominal WDT clock speed) would give it added value.
Regards
Mark
ps the SLEEP icon would need a check box to optionally add a NOP after the Assembler sleep command (see data sheet).
pps In any case, these two suggestions give you just about the easiest 'win' in adding useful functionality to Flowcode that I can imagine and would be more widely usable than, say I2C etc.?
Go with the Flow.
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Thanks for your thoughts, Mark
I think our position on this has to be that use of the watchdog timer, and the sleep function for that matter, are advanced features.
This functionality is easily accessible via a 'C' icon with a simple line or two, which is easy enough to implement by the majority of Flowcode users (with information and help gained via this forum!).
I think our position on this has to be that use of the watchdog timer, and the sleep function for that matter, are advanced features.
This functionality is easily accessible via a 'C' icon with a simple line or two, which is easy enough to implement by the majority of Flowcode users (with information and help gained via this forum!).