Description
u8_trigger_wdog()
triggers the watchdog. If the watchdog is activated then this function needs to be called regularly by the application. The time [seconds] after which the watchdog will reset the device in case it does not get triggered by the application can be set in the bootloader settings.
Enable and configure the watchdog time either with the dice-configTool or the with the function u8_set_app_watchdog_time_sec().
Syntax
u8_trigger_wdog();
Parameters
none
Returns
uint8_t –
0: watchdog is not active
1: OK. Watchdog successfully triggered
Example Code
This example shows how to read, set and store the ‘application watchdog time’ of the bootloader settings and how to trigger the watchdog.
void setup()
{
Serial.begin();
while (!Serial)
{
yield(); // wait for PC CAN2SER-monitor to open
}
Serial.println("Current bootloader settings:");
Serial.print(" - app. watchdog: ");
if(BOOTLOADER_SETTING.u8_get_app_watchdog_time_sec() != 0)
Serial.println( String( BOOTLOADER_SETTING.u8_get_app_watchdog_time_sec() ) + "sec");
else
Serial.println( String("off"));
delay(2000);
Serial.println("Modify the settings");
BOOTLOADER_SETTING.u8_set_app_watchdog_time_sec(8);
delay(2000);
Serial.println("Store the settings in flash");
uint8_t u8_ret = BOOTLOADER_SETTING.u8_store_bootloader_settings();
if(u8_ret != 0)
Serial.println("Error writing into flash");
Serial.println("DONE");
}
void loop ()
{
BOOTLOADER_SETTING.u8_trigger_wdog();
}
Notes and Warnings
If you make use of the watchdog, always make sure that the application will trigger the watchdog in time. Pay particular attention if you are using libraries that do not do trigger the watchdog and that might have function return times that are longer or hard to predict.
See also
u8_set_app_watchdog_time_sec()
u8_get_app_watchdog_time_sec()