Hello @Kan_Li, I want to use a watchdog timer. I am unable to find standard examples regarding the initialization and handling of the watchdog timer. I have referred user manual as "https://www.nxp.com/docs/en/user-guide/UM10913.pdf". According to it, I have start watchdog using phhalWdt_Start() API. and register a callback in which I am turning on GPIO to check callback is triggered or not.
void test_wdtg_callback()
{
PH_HAL_GPIO_SETGPIOVAL( 5 , true);
}
void wdt_test()
{
phhalWdt_DeInit();
uint16_t timeout = 1023;
uint16_t timeout_threshold = 1023/2;
uint8_t bResetOnTimeOut = 0;
phhalWdt_Start(timeout,timeout_threshold,test_wdtg,bResetOnTimeOut);
phhalWdt_Refresh();
}
But When my firmware executes wdt_test() API board is getting a reboot after ~22 seconds but with reboot reason 0x0a (software reset). Also, I am not able to get interrupt as well.
Can you please help and let me know if I am doing anything wrong or missing anything?
Also, it will be good to provide a reference code to configure and reload watchdog.
Hi @pratikyadav ,
The NMI interrupt is used for WDT, but did you enable it explicitly ? Please kindly refer to phhalNvic.h for more details.
Hope that helps,
Have a great day,
Kan
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thanks, @Kan_Li for your response.
I have not enabled NMI.
I have tried to enable NMI using "phHal_Nvic_EnableInterrupt(PHHAL_NVIC_NMI)", But as PHHAL_NVIC_NMI is not defined, I am getting a compilation error. Is there another way by which I can enable NMI interrupt?
Another issue which I am facing is that I am getting reboot reason software reboot instead of watchdog reboot. Can you please guide me regarding this?
Hi @pratikyadav ,
Sorry , my fault. The NMI interrupt is enabled by default, so no need to define PHHAL_NVIC_NMI , but after reviewing your code, I found two issues:
1. You defined test_wdtg_callback(), but it is not used for phhalWdt_Start(), test_wdtg is used instead. How is it implemented? maybe it leads to a SW reset.
2. phhalWdt_Refresh() is not needed after phhalWdt_Start() in which phhalWdt_Refresh() is called.
The following is the code tested on my side:
void test_wdtg_callback()
{
DEBUG_PRINTF("\n WDT interrupt! \n");//PH_HAL_GPIO_SETGPIOVAL( 5 , true);
}
void wdt_test()
{
phhalWdt_DeInit();
uint16_t timeout = 1023;
uint16_t timeout_threshold = 1023/2;
uint8_t bResetOnTimeOut = 0;
phhalWdt_Start(timeout,timeout_threshold,test_wdtg_callback,bResetOnTimeOut);
}
and the result is shown as below:
Have a great day,
Kan
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------