Watchdog and 'System.InvalidOperationException

Hi,
I use a watchdog ine my fezcerb40 ii. (doc : https://www.ghielectronics.com/docs/31/watchdog)
I initialise in the main by ;
GHI.Processor.Watchdog.Enable(1000 * 15);

But I have some time this exception ‘System.InvalidOperationException’ and I do not understand why.
I try do add
if(! GHI.Processor.Watchdog.Enable)
before, but it changes nothing.

And my timeout is not too short.

so why i have this exception ?

@ francois910 - Can you show us the stack trace and any message that is given with the exception?

Try adding a “using” statement:



Then call from code:


```cs]wd.Enable(1000 * 15);[/code

@ stevepx i’m in 4.3 and GHI.Premium not exist in this

@ John

‘Une exception non gérée du type ‘System.InvalidOperationException’ s’est produite dans GHI.Hardware.dll’ -> it’s the pop up

‘Une exception de première chance de type ‘System.InvalidOperationException’ s’est produite dans GHI.Hardware.dll
Une exception non gérée du type ‘System.InvalidOperationException’ s’est produite dans GHI.Hardware.dll’ -> in the windows output

This is what you wanted?

@ francois910 - You should also see something similar to the below in the output window. That is the stack trace I need.

#### Exception System.InvalidOperationException - 0x00000000 (1) ####
#### Message: 
#### Hardware.Program::Foo [IP: 0003] ####
#### Hardware.Program::Main [IP: 0003] ####

A first chance exception of type ‘System.InvalidOperationException’ occurred in Hardware.exe
An unhandled exception of type ‘System.InvalidOperationException’ occurred in Hardware.exe

Ok,

i have not found (i look all windows)
Screen of my output underside

In the first deploy (when i use watchdog) i haven’t error, but in the second and other yes.

@ francois910 - Can you look in the call stack window? If you can’t find it, see if you can enable it under Debug > Windows > Call Stack when debugging.

Is the watchdog timer being enabled more than one in the program?

Screen with my call stack

@ mike : i just enable in the start of my main.
I test using disabled before but i have the same error.

@ francois910 - Does the below program give the exception every time it’s ran?


public static void Main()
{
    Watchdog.Enable(1000 * 15);

    while (true)
    {
        Watchdog.ResetCounter();

        Thread.Sleep(1000);
    }
}

Yes, i have exception every time with this code

(i use GHI.Processor.Watchdog… because watchdog is in Microsoft.SPOT.Hardware and GHI.Processor)

@ francois910 - I was not able to reproduce the issue using the latest beta 3 firmware. Which version are you running? Have you tried a different Cerberus board if you have any? Can you reflash the firmware and try again?

i use 4.3

I haven’t Cerberus board.

But now I have a problem recognition hardware so I can not do reflash. (This is another problem that one.)

@ francois910 - Any Cerb family board will do, another Cerb 40 II, Cerberus, or Cerbuino. Can you put the board into DFU mode and try to reflash the loader?

Ok,
i take a second fez cerb 40 ii and i reflash the loader. It was in 4.2 and i put the 4.3.

So in the first use, no problem, but when i put for the second time the program, i have the same exeption.

And, when i put your code, 1st time no problem, but i have exeption in 2nd time.

code (for your test) it"s just :


using System.Threading;
using GHI.Processor;



namespace testODB
{
    public class Program
    {
        


        public static void Main()
        {
            Watchdog.Enable(1000 * 15);

            while (true)
            {
                Watchdog.ResetCounter();

                Thread.Sleep(1000);
            }
        }

    }

}

francois910 - We are still unable to reproduce the issue. Can you try using the just released SDK?

I put the 4.3.3.

1st time it’s good, 2nd time exeption^^

@ francois910 - Can you take a screenshot of the window that pops up when you get the exception?

it’s done.

@ francois910 - When you run the program the second time, do you unplug the board at all or do you just restart the program in Visual Studio?