watchdog and Wireless Programming

Started by Bruno, April 13, 2015, 04:11:02 AM

Bruno

I needed to program a watchdog 2s in my project, unfortunately, when I want to update the firmware with CheckForWirelessHEX, transmission is cut after 2 seconds (normal). Can you tell me what changes I need to do in the library WirelessHEX69 to keep watchdog_2s and CheckForWirelessHEX work?

TomWS

Quote from: Bruno on April 13, 2015, 04:11:02 AM
I needed to program a watchdog 2s in my project, unfortunately, when I want to update the firmware with CheckForWirelessHEX, transmission is cut after 2 seconds (normal). Can you tell me what changes I need to do in the library WirelessHEX69 to keep watchdog_2s and CheckForWirelessHEX work?
Do you mean that you use the WatchDog timer to provide a periodic interrupt every two seconds?  If so, then that is totally incompatible with the general principle of the Wireless Programming Library - it would be a major rip-up to change (unless you're willing to disable this 2 second interrupt when the wireless program download begins).  However, if all you need is a 2 second periodic interrupt, why not use Timer1 or Timer2 for this purpose?

Tom

Felix

Can you stop the timer before calling CheckForWirelessHEX? Then restart it after the call?

Bruno

#3
I implemented a wdt_disable() before CheckForWirelessHEX and it works -Thanks Felix.

But I have another problem:

I use moteino on voltage 230V for measuring powers. (transformerless)

Today, I submitted the electrical installation to strong disturbances (European standards tests) and the watchdog doesn't always work (frozen half the time). I learned that it could be from the optiboot bootloader. https://tushev.org/articles/arduino/5/arduino-and-watchdog-timer

Is that the problem is due to the bootloader?

if I change DualOptiboot.c, line 677
         CheckFlashImage();
by
         appStart(ch);
do I have a chance of success?

Felix

If you want wireless programming you will need DualOptiboot AS IS.
The WirelessHEX69 lib will do a watchdog timeout to cause a soft reset of the MCU. The bootloader checks if reset was caused by watchdog via the reset flags but otherwise the bootloader does not have anything to do with the watchdog timer.