Watchdog time setting.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Watchdog time setting.

530 Views
tedwu1
Contributor III

Hi friend,

I am using Q9021 and BLE SDK 1.0.0. I set the watchdog timer to 5 seconds. I made an infinite loop to test the watchdog. But it resets after 10 seconds. How can I make the watchdog time 5 seconds? How to remove the intermediate stage as shown. The code snippet is as follows.

Thank you in advance.

Ted Wu

int main(void)
{
...

#if (defined(QN_ADV_WDT))
    wdt_init(163840, WDT_RESET_MOD); // 5s
    usr_env.adv_wdt_enable = true;
#endif

...

}

void usr_sleep_restore(void)
{
#if QN_DBG_PRINT
    uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600);
    uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE);
    uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE);
#endif

#if (defined(QN_ADV_WDT))
    if(usr_env.adv_wdt_enable)
    {
        wdt_init(163840, WDT_RESET_MOD); // 5s
}
#endif
}

#if CONFIG_WDT_DEFAULT_IRQHANDLER==TRUE
void WDT_IRQHandler(void)
{
    if (reset_test == 1){ /* When testing watchdog reset, need to stay in WDT_IRQHandler until the watchdog overflows again */
        while (1) {
            // wait for reset...
        }
    }
#if def BLE_PRJ
#if (defined(QN_ADV_WDT))
    usr_env.adv_wdt_to();
#endif
#endif
    wdt_irq_clear(); /* Deassert Watchdog interrupt */

}
#endif /* CONFIG_WDT_DEFAULT_IRQHANDLER==TRUE */

 

 

未命名.png

0 Kudos
3 Replies

513 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @tedwu1

Hope you are doing well.

QN9021 SDK version 1.0.0 is out of date, would it be possible for your application to migrate to SDK version 1.4.0? Also, please consider that QN9090/30 is preferred for any new design.

This should be an expected behavior. As you mentioned, User Manual of QN902x [UM10996] Chapter 13 Watch-Dog Timer describes that the module generates a regular interrupt (WDOGINT), the watchdog monitors the interrupt and asserts a reset (WDOGRES) signal, when the counter reaches 0, and the counter is stopped. You can find a WDT demo inside QN902x SDK 1.4.0 > Projects > Driver > wdt.

Regards,
Eduardo.

0 Kudos

504 Views
tedwu1
Contributor III

Hello @EduardoZamora 

I know QN9021 SDK version 1.0.0 is out of date. My application cannot be migrated to SDK version 1.4.0? This is an old project and currently only maintained. We don't want to make big changes. I have seen the WDT demo of QN902x SDK 1.4.0 > Projects > Driver > wdt. There is no difference with QN9021 SDK version 1.0.0. Can I add syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_REBOOT_SYS) to the following program? Keep WATCHDOG for 5 seconds. Will this eliminate the high current phenomenon? Why is watchdog enabled, but why does it sometimes fail? This phenomenon is difficult to replicate. I set the watchdog to reset mode. wdt_init(163840, WDT_RESET_MOD); Why does the code enter WDT_IRQHandler not directly reset the system?

Thank you very much.

Ted Wu

at wdt.c

 

 

#if CONFIG_WDT_DEFAULT_IRQHANDLER==TRUE
void WDT_IRQHandler(void)
{
    if (reset_test == 1){  /* When testing watchdog reset, need to stay  in WDT_IRQHandler until the watchdog overflows again */
        //Reset system.
        syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_REBOOT_SYS);
        while (1) {
        // wait for reset...
        }
    }
#ifdef BLE_PRJ
#if (defined(QN_ADV_WDT))
    usr_env.adv_wdt_to();
#endif
#endif
    wdt_irq_clear(); /* Deassert Watchdog interrupt */

}
#endif /* CONFIG_WDT_DEFAULT_IRQHANDLER==TRUE */

 

 

 

0 Kudos

489 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

According to the WDT operation flow, reset signal is asserted after WDOGINT is asserted and the counter reaches zero / is stopped. 

EduardoZamora_1-1669849373506.png

 

Please, test the WDT Driver example, just to confirm that the module is working properly.

You can take a look at the prj_ancsc, part of the Bluetooth Low Energy example projects. This demo implements the WDT (#define QN_ADV_WDT 1 macro is required in usr_config.h) and should implement the Sleep Driver by default; please, use this example as base for a comparison.

Regards,
Eduardo.

0 Kudos