Page 1 of 1

Detection where Watchdog timeouts occure?

Posted: Tue Sep 06, 2016 12:59 pm
by Konstantin
Hey!

Currently I'm working on a project to get the SitAw-modul functional. Topic: viewtopic.php?f=6&t=2115
I think I have a good concept for the flying/-landing-state-issue (by implementing the estimated Altitude). My Code (github: https://github.com/Koschu/Crazyflie-Sit ... ementation) stands compiling and flashing steps, but when the FreeFallDetection triggers, a watchdog-timeout occures and the red light blinks 5 times. If i get it right, this indicates a loop in the code or the function is too large/complex for the processor.
It seems like the very problem is the implementation of the estimated Altitude. As soon, as I doubledash the line "High=GetEstimatedPositionAsFunction ();" (line 167 in sitaw.c) and all connected lines, the CF runs without a timeout (but without the important function, too).

So I have 2 Questions:
First: Is there an opportunity to find the reason for a watchdog timeout without using the debug adapter (which I did not buy yet)?
Second (just for those who are interested in this project): Any Idea what could have caused this specific watchdog timeout?

Re: Detection where Watchdog timeouts occure?

Posted: Wed Sep 07, 2016 9:04 am
by tobias
Hi Konstantin!

You have just hit a tricky subject and we don't have a optimal idea of the watchdog yet. The general thought is that if idle task isn't allowed to run at lease once every ~300ms, something is probably implemented wrong. Finding out what that is can be difficult though. Implementing logging of task execution times is one way to do it but debugging with SWD will not help as there is no simple way to find out what took all the time.

In your case I doubt the calculations in the function GetEstimatedPositionAsFunction takes that much time so I'm thinking a hard fault happens (this isn't currently logged so the watchdog can find it). This will still happen if you disable the watchdog (compile in in debug with flag DEBUG=1) so check that.

Re: Detection where Watchdog timeouts occure?

Posted: Wed Sep 07, 2016 1:27 pm
by Konstantin
Hey Tobias,

thanks for the reply! =) As you doubt, the GetEstimatedPositionAsFunction was that little imp that triggered the watchdog. I tested that by commenting out these lines. Fortunately I found another way to implement the estimated Altitude and now the SitAw module does the job I wanted it to do!

I'll put the "DEBUG=1 - hint" in my trick-box for further programming =)