Watchdog on BGM111 (and other Blue Gecko modules / boards)

by <a href=""><font color="#000000"><font size="2">Hero Employee</font></font> </a> arkalvac on ‎02-23-2017 07:26 AM


If you want to use watchdog timer on any Blue Gecko boards / modules, do the followings:


1) Create a new C project in Simplicity Studio


2) copy em_wdog.c into the project from:



3) #include "em_wdog.h"


4) Configure the watchdog timer:


WDOG_Init_TypeDef init =
.enable = true, /* Start watchdog when init done */
.debugRun = false, /* WDOG not counting during debug halt */
.em2Run = true, /* WDOG counting when in EM2 */
.em3Run = true, /* WDOG counting when in EM3 */
.em4Block = false, /* EM4 can be entered */
.swoscBlock = false, /* Do not block disabling LFRCO/LFXO in CMU */
.lock = false, /* Do not lock WDOG configuration (if locked, reset needed to unlock) */
.clkSel = wdogClkSelULFRCO, /* Select 1kHZ WDOG oscillator */
.perSel = wdogPeriod_2k, /* Set the watchdog period to 2049 clock periods (ie ~2 seconds)*/



5) Feed the watchdog before the counter overflows, e.g. using a soft timer:


while (1) {
struct gecko_cmd_packet* evt;
evt = gecko_wait_event();

switch (BGLIB_MSG_ID(evt->header)) {

case gecko_evt_system_boot_id:
/* Start soft timer to feed the watchdog every second.
* If the stack freezes, the soft timer will stop, and the watchdog will not be fed. */

case gecko_evt_hardware_soft_timer_id:
/* Feed the watchdog every second while the stack is running */

default: break;


6) Check at the beginning of main() if the reset was caused by watchdog


uint32_t resetCause = RMU_ResetCauseGet();

/* Check if the watchdog triggered the last reset */
if (resetCause & RMU_RSTCAUSE_WDOGRST)
/* watchdog reset occured */

You have to add em_rmu.c to the project and include "em_rmu.h" to implement this last step


Attached you can find an example project using wathchdog on BGM111 using Bluetooth SDK v2.1.1.