Basic System Monitor Example
Use a system monitor to enable Gecko OS to supervise app behaviour.
- SDK directory:
API Features Demonstrated
This app works on:
Requirements and Prerequisites
Requires a Gecko OS evaluation board, such as a WGM160P_eval.
Other Gecko OS hardware can also be used by changing the source of the logged data to suit your device.
The system monitor provides a way for Gecko OS to ensure that an application does not hang.
A system monitor is registered to trip a watchdog alarm if it is not updated within a specified time.
The app creates a system monitor update event to update the system monitor within the specified time, as long as the app is working properly.
If the app fails to update the system monitor, the alarm goes off and the watchdog reboots the system.
In this demonstration, the app ensures that the system monitor update only works three times.
Output is similar to the following:
Updating system monitor Updating system monitor Updating system monitor Simulating system lock up, watchdog will be triggered in 7 seconds ... 1: Watchdog Exception, uhandle:00 bhandle:37 PC:0x1A009CC8 LR:0x1A01CC27
The app registers a system monitor by calling gos_register_system_monitor, specifying a maximum time between updates of
Once the monitor is registered, gos_update_system_monitor must be called before
MAX_DELAY milliseconds expires, otherwise a watchdog fault will occur, causing a system reset.
The call to gos_event_register_periodic registers a periodic update handler to be called every
MAX_DELAY/2 milliseconds. This should ensure timely updates of the system monitor.
However the handler
update_system_monitor_event_handler ensures that the update does not occur, by de-registering the monitor update periodic event after the third update.
Note: De-registering the update event is intended to demonstrate the triggering of the watchdog, rather than to serve as an example of best practice system monitor event handling.
gos_app_deinit a call to gos_unregister_system_monitor unregisters the monitor event.