清看门狗时间将近2.8ms,时间长,问题已找到,只是不知道怎么修改,请大家指点~测试程序如下:
#include <asf.h>
void configure_wdt(void);
void configure_wdt(void)
{
struct wdt_conf config_wdt;
wdt_get_config_defaults(&config_wdt);
config_wdt.always_on = false;
#if !((SAML21) || (SAMC21) || (SAML22))
config_wdt.clock_source = GCLK_GENERATOR_4;
#endif
config_wdt.timeout_period = WDT_PERIOD_64CLK;
wdt_set_config(&config_wdt);
}
int main(void)
{
system_init();
delay_init();
//! [setup_init]
configure_wdt();
//! [setup_init]
port_pin_set_output_level(PIN_PA22,0);
wdt_reset_count();
while (true) {
//! [main_3]
//port_pin_set_output_level(PIN_PA22,1);
//wdt_reset_count();
port_pin_set_output_level(PIN_PA22, 1);
port_pin_set_output_level(PIN_PA22, 0);
wdt_reset_count();
port_pin_set_output_level(PIN_PA22, 1);
port_pin_set_output_level(PIN_PA22, 0);
port_pin_set_output_level(PIN_PA22, 1);
port_pin_set_output_level(PIN_PA22, 0);
delay_ms(5);
}
//! [main]
}
wdt_reset_count函数如下:
void wdt_reset_count(void)
{
Wdt *const WDT_module = WDT;
/* Disable the Watchdog module */
WDT_module->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
while (wdt_is_syncing()) {
/* Wait for all hardware modules to complete synchronization */
}//while循环等待时间过长,接近2.8ms,这段代码不要会不会有问题?或是怎样修改又不会占用很多时间,How to do???
}
请大家帮忙一起看看,谢谢各位~
同时今天祝女同胞们节日快乐!O(∩_∩)O哈哈~
|