Page 1 of 2

Enable Hardware Watchdog

Posted: 19 Oct 2017 12:51
by apica
Hello,

I'd like to enable the internal Watchdog. I saw an viewtopic.php?f=3427&t=25195 but it's not available in the last release (2.1.1), and I need an urgent solution.

How can I enable the watchdog? Which commands (and how) are needed?

Thank you.

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 16:53
by PoltoS
Why do you need it? Does your Z-Uno hangs? Internal WatchDog is pretty tricky - you can not configure it's grace period, so you might have problems with even on valid sketches. Better to solve the problem that causes the hang

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 17:02
by apica
Thank you for your reply.

Yes, it hangs after a while. There is a problem when i read with ADC (analogRead) after a while. I found that moving all local variables (just few uint16_t) to a global scope and merging code (to avoid entering to a functions and increasing stack), the problem is solved. But this solution doesn't give me very confidence because it seems to be related to an internal issue.

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 17:11
by petergebruers
@apica, have you tried 2.1.1 yet? I can recommend it, it contains a lot of improvements. And if it does not, I offer you a helping hand, ... Please let me know what you think...

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 17:13
by petergebruers
Forgot something important... there is an issue with that version on windows, if your user directory has a space in its path...

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 17:38
by apica
Yes!

I'm using the 2.1.1 from yesterday (I had the same problem with 2.1.0).

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 18:06
by PoltoS
We can try to investigate your issue if you provide the sketch and a way to reproduce the problem

Re: Enable Hardware Watchdog

Posted: 19 Oct 2017 18:24
by apica
@PoltoS, I've send you a private message with the sketch. I prefer to not make it public for the moment.

Thank you

Re: Enable Hardware Watchdog

Posted: 20 Oct 2017 16:49
by PoltoS
We have cheked your sketch. Clearly, it overflows the stack. You can check this in the debug output once enabled in the ArduinoIDE.

We suggest to use less float (don't multiply by g and then device back). Try to minimized numbers of nested functions and make more glabal variables and/or make them smaller size.

Code: Select all

0056:A0 00...
Period Average = 6.89
Send report
ADC: 779   Bat: 3089.87   V: 2352   R: 313   F: 66.11   W: 6.74
0056:A0 00
ADC: 785   Bat: 3089.87   V: 2370   R: 303   F: 68.08   W: 6.94
ADC: 779   Bat: 3089.87   V: 2352   R: 313   F: 66.11   W: 6.74
ADC: 786   Bat: 3089.87   V: 2373   R: 301   F: 68.47   W: 6.98
Note the

Code: Select all

A0 00
check it agains this table: https://github.com/Z-Wave-Me/Z-Uno-Core ... ons.h#L130

Re: Enable Hardware Watchdog

Posted: 20 Oct 2017 17:00
by apica
Thank you @PoltoS.

I've tried enabling the output Log on UART0, but it didn't appeared (I'll check it again) -> EDIT: I didn't know about that codes and the meaing! Thank you!

The stack usage shouldn't be that high (the same code runs in all arduino boards I tried). How big is the stack? Any way to determine/estimate the stack used?

Thank you