设置喂狗时间为1S,并添加M3指令为复位指令,但是可能无效。修改了数据获取方式,从一直持续获取改为每次申请获取。

This commit is contained in:
2024-12-27 00:09:53 +08:00
parent 9a07dba591
commit 4d98e4dc30
6 changed files with 47 additions and 25 deletions

View File

@@ -23,16 +23,24 @@ void watchdog_init(void) {
rcu_osci_on(RCU_IRC40K);
rcu_osci_stab_wait(RCU_IRC40K);
/* Enable the FWDGT clock */
// rcu_periph_clock_enable(RCU_FWDGT);
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 256 = 0.15625 KHz */
fwdgt_config(625, FWDGT_PSC_DIV256); // Set timeout to 4 seconds (625 / 0.15625 KHz)
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
/* Enable FWDGT */
fwdgt_enable();
}
void reset_mcu(void) {
/* Enable the write access to the FWDGT_CTL register */
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
/* Configure FWDGT to trigger a system reset */
fwdgt_config(5, FWDGT_PSC_DIV4);
/* Reload the counter to trigger the reset */
fwdgt_counter_reload();
}
/*!
\brief main function
\param[in] none
@@ -57,14 +65,10 @@ int main(void) {
/* Initialize watchdog */
watchdog_init();
printf("Hello, world!\n");
while (1) {
delay_ms(99);
g_eddy_current_value_uint32 = 0;
g_temperature_uint32 = 0;
g_eddy_current_value_uint32 = ldc1612_get_raw_channel_result(CHANNEL_0);
g_temperature_uint32 = tmp112a_get_raw_channel_result();
// printf("1");
fwdgt_counter_reload();
}
}