27.8.2.1.2 Code
Copy-paste the following setup code to your user application:
Add to user application initialization (typically the start of main()):voidwatchdog_early_warning_callback(void){port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);}voidconfigure_wdt(void){/* Create a new configuration structure for the Watchdog settings and fill* with the default module settings. */structwdt_conf config_wdt;wdt_get_config_defaults(&config_wdt);/* Set the Watchdog configuration settings */config_wdt.always_on =false;#if !((SAML21) || (SAMC21) || (SAML22))config_wdt.clock_source = GCLK_GENERATOR_4;#endifconfig_wdt.timeout_period = WDT_PERIOD_4096CLK;config_wdt.early_warning_period = WDT_PERIOD_2048CLK;/* Initialize and enable the Watchdog with the user settings */wdt_set_config(&config_wdt);}voidconfigure_wdt_callbacks(void){wdt_register_callback(watchdog_early_warning_callback,WDT_CALLBACK_EARLY_WARNING);wdt_enable_callback(WDT_CALLBACK_EARLY_WARNING);}
configure_wdt();configure_wdt_callbacks();
