Assuming that I wanna enable Watchdog, and timeout is set to maximum (2.1 s) :
- To periodically reset Watchdog, should I include the (assembler) instruction WDR, especially into loops which are waiting (repeat until) for a condition related to input lines states ? I didn't even try using Wait for this purpose ... if it's even possible : I don't think it is so for a combination of several lines, the only solution beeing my solution with masking ?
- I took a glance to the ASM code generated by the present version of my program (not yet using Watchdog), and didn't see any WDR included automatically, despite of the fact that I use Wait for delays ; does it mean that WDR is not included in delaying loops (and probably in no other WAIT loop), and so a delay of more than about 2.1 s cannot be used with Wait because this would cause a Reset by Watchdog ? And so I should split my delay into severar "Wait"'s
Thanks for any answer ...
Last edit: Bertrand BAROTH 2018-04-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No I don't use any bootloader, I will program my chip (not even in circuit) only on the corresponding socket on STK200 ; I didn't yet set the fuse, and the configuration will be set properly, according to delay of 2.1 s and startup time of 65 ms ...
Last edit: Bertrand BAROTH 2018-04-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Lots of different scenario's when using WDT and timing functions. Something the user needs to explore to see which suits the project at hand.
Will the device make use of sleep command? I have used the WDT itself as the wait command by waking up, increment a counter, go back to sleep, and when counter value reached (like say 10 minutes later), then execute code.
If continously powered up then I would think about stepping away from the wait command (if there are a lots of them?), and use say TMR0 interrupt, and again use a variable to count (say every second), and clear the WDT there.
If accuracy is required then have used the DS1307 to do the counting. Either read the registers, or enable the 1 sec square wave output to one's advantage.
One last thought is to make a sub for the waits and use a Do...Loop of much shorter waits, put the clear WDT there so as not to timeout with the WDT. Count loops and exit when conditional statements and flags, say to do so.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In fact, since all delays of more than 500 ms are multiples of 500 ms and accuracy is not needed (it is a sequencer for a model railroad layout), my idea is a "for ... next" loop with a "Wait 500 ms" and a WDR inside (see attchment).
Hello ...
Assuming that I wanna enable Watchdog, and timeout is set to maximum (2.1 s) :
- To periodically reset Watchdog, should I include the (assembler) instruction WDR, especially into loops which are waiting (repeat until) for a condition related to input lines states ? I didn't even try using Wait for this purpose ... if it's even possible : I don't think it is so for a combination of several lines, the only solution beeing my solution with masking ?
- I took a glance to the ASM code generated by the present version of my program (not yet using Watchdog), and didn't see any WDR included automatically, despite of the fact that I use Wait for delays ; does it mean that WDR is not included in delaying loops (and probably in no other WAIT loop), and so a delay of more than about 2.1 s cannot be used with Wait because this would cause a Reset by Watchdog ? And so I should split my delay into severar "Wait"'s
Thanks for any answer ...
Last edit: Bertrand BAROTH 2018-04-05
Are you a bootloader? As this may constrain Watchdog usage. What are the current config switches set to?
No I don't use any bootloader, I will program my chip (not even in circuit) only on the corresponding socket on STK200 ; I didn't yet set the fuse, and the configuration will be set properly, according to delay of 2.1 s and startup time of 65 ms ...
Last edit: Bertrand BAROTH 2018-04-05
No more answers ? Am I right with my ideas ?
As you are not using a bootloader the switches is a good way to go.
We really need one of the AVR guys to answer this - as I am not expert on these switches and the assiocated registers.
Lots of different scenario's when using WDT and timing functions. Something the user needs to explore to see which suits the project at hand.
Will the device make use of sleep command? I have used the WDT itself as the wait command by waking up, increment a counter, go back to sleep, and when counter value reached (like say 10 minutes later), then execute code.
If continously powered up then I would think about stepping away from the wait command (if there are a lots of them?), and use say TMR0 interrupt, and again use a variable to count (say every second), and clear the WDT there.
If accuracy is required then have used the DS1307 to do the counting. Either read the registers, or enable the 1 sec square wave output to one's advantage.
One last thought is to make a sub for the waits and use a Do...Loop of much shorter waits, put the clear WDT there so as not to timeout with the WDT. Count loops and exit when conditional statements and flags, say to do so.
In fact, since all delays of more than 500 ms are multiples of 500 ms and accuracy is not needed (it is a sequencer for a model railroad layout), my idea is a "for ... next" loop with a "Wait 500 ms" and a WDR inside (see attchment).
Last edit: Bertrand BAROTH 2018-04-08
There you go then. Context is everything... :)