[Atria AT32WB415 Series Bluetooth BLE 5.0 MCU] WDT Watchdog Analysis and Application
I am honored to have the opportunity to review the Arteli AT32WB415 series Bluetooth BLE 5.0 MCU. For this reason, in accordance with my previous review habits, my Github : All review codes are open source and shared.
If you cannot access Github due to network problems, you can download it from Gitee. It may not be updated in time. Gitee: My_AT32WB415_Demo: Arteli Technology AT32WB415 series learning, starting from each peripheral, learning each function. (gitee.com)
1. Watchdog
The watchdog consists of a 12-bit down counter and an 8-bit prescaler. It is clocked by the low-speed internal LICK; because this clock is independent of the main clock, it can run in deep sleep and standby modes. It can be used as a watchdog to reset the entire system when an error occurs, or as a free timer to provide timeout management for the application. Whether the watchdog starts automatically can be configured through user system data. In debug mode, the counter can be frozen.
Let's focus on the command register and the reload register.
Let's take a look at the calculation of the dog feeding timeout. First, let's look at a table:
Let’s look at the calculation formula:
2. Code Analysis
void wdt_init(void)
{
if(crm_flag_get(CRM_WDT_RESET_FLAG) != RESET)
{
/* reset from wdt */
crm_flag_clear(CRM_WDT_RESET_FLAG);
}
/* disable register write protection */
wdt_register_write_enable(TRUE);
/* set the wdt divider value */
wdt_divider_set(WDT_CLK_DIV_4);
/* set reload value
timeout = reload_value * (divider / lick_freq ) (s)
lick_freq = 40000 Hz
divider = 4
reload_value = 3000
timeout = 3000 * (4 / 40000 ) = 0.3s = 300ms
*/
wdt_reload_value_set(3000 - 1);
/* enable wdt */
wdt_enable();
}
And the reload value API:
/* reload wdt counter */
wdt_counter_reload();
3. Effect display
There is nothing much to show in this part. If you are interested, you can go to the repository to see the complete code.