Main Site Documentation

Snippet - Cerb-Family Hardware Watchdog


I just posted Cerb-Family Hardware Watchdog on Codeshare. Feel free to discuss and make suggestions here.


nice :slight_smile:

what is need to allow intervalSeconds as variable?


Great Question. It’s actually probably easy… The register WDG_RLR stores the countdown start value. Dividing it by half (0x7FF) would probably give you about 16 seconds. So the original code is this:

IWDG_RLR.SetBits(0xFFF); // Set starting number for countdown in watchdog 0xFFF is about 32 seconds

My guess is that changing to something like this would work:

IWDG_RLR.SetBits(0xFFF * (Math.Min(intervalSeconds, 32) / 32)); // Set starting number for countdown based on intervalSeconds


Thank you for posting your implementation of the watchdog.

I have 7 Cerbuino Bees deployed as environmental monitors at work. I use the webserver to serve up html when our system hits them. They have not been entirely reliable and need to be reset periodically. I have been using PowerState.RebootDevice(true) to force resets at regular intervals but in some cases this has not worked.

I will be testing code with your watchdog this week. Again, thank you.


I think you’re going to be a VERY happy camper. I have a web server running on a Cerb40 (and mIP of course) based device that is going on about 10 months of non-stop operation, likely thanks to this watchdog. I literally have not touched it in 10 months. This watchdog is the key to long term reliability and the LowLevel library from GHI is THE reason I moved to this platform. I also implemented my own RTC but GHI implemented that one and built it in shortly after I finished mine.

There are other great features that could be implemented with these classes and I encourage everyone to look at the STM32F4XX spec sheet! You can see from this example that it can be a fairly straightforward implementation…


Thanks Valkyrie-MT for all your contributions, you have been a huge help to this community…

so thank you :slight_smile:


Thanks Valkyrie-MT, I have been testing this code on 7 cerbuinos the last 3 days and have not had a single problem. I really appreciate the help.