Snippet - Cerb hardware watchdog

I just posted Cerb hardware watchdog on Codeshare. Feel free to discuss and make suggestions here.

4 Likes

I liked this implementation, but it didn’t work for me. Using 5 seconds worked fine, but anything above that triggered a reset. Like, I called Init for 16 seconds and instantly the board rebooted.

I switched to this code for now…

http://netmf-develop.blogspot.tw/

Thank you for pointing that out. I will check that.

Values above 5s worked fine for me. Just be sure you are calling the Init method with a microsecond value.

 CerbWatchdog.Init(5000000);

5,000,000 microseconds =5 seconds.

CerbWatchdog.Init(5000) = Immediate reboot

maybe adding a check and throw an exception if someone initialize the watchdog with anything below the minimum value say 5 Seconds.
Cheers,
Jay.

For some strange reason this is not working for me.
The system reset immediately after calling the Init method. Both codes (http://netmf-develop.blogspot.tw/)

        void ProgramStarted()
        {
            Mainboard.SetDebugLED(true);
            Debug.Print("started");            

            GT.Timer timer = new GT.Timer(30000);
            timer.Tick += (GT.Timer t) =>
                {
                    Debug.Print("dog reset");
                    WatchDog.Reset();
                };
            timer.Start();

            _Vticnica = breakout.SetupDigitalOutput(GT.Socket.Pin.Three, false);
            _temphum = new TemperatureHumidityMeasuring(temperatureHumidity, PostValues);
            _temphum.HumidityChanged += new TemperatureHumidityChangedDelegate(_temphum_HumidityChanged);

            new Thread(() =>
                {
                    InitializeNetwork();
                });
            
            Thread.Sleep(20000);
            Mainboard.SetDebugLED(false);
            Debug.Print("before");
            Thread.Sleep(500);
            WatchDog.Init(32768000);
            Debug.Print("before");         
        }

Immediately after getting before the cerb resets.

@ Makla: Thank you for you helping me finding bug. It is true, is some cases Cerb restarted instantly. Bug is fixed; the new code is available on codeshare. But be careful, watch dog clock can vary, so even if you set watch dog to 32s, you should reset it much faster. In my test it was about 28s.

Other who has problems with instant resets, please be careful with Init method, where you need to specify timeout in microseconds! But if you still have problems please provide me a test case.

It’s been a long time, I’m sorry. But I ask you a question required;
Deepsleep mode and then entering the WatchDog continues. How do I turn off before you go to sleep.

Thanks