How to use Watchdog Interrupt in KE02

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

How to use Watchdog Interrupt in KE02

Jump to solution
2,097 Views
xpress_embedo
Contributor II

Hello Everyone,

I am working on a project, based on Kinetics KE02 micro-controller and I am facing a problem, where system is resetting due to WatchDog timeout, so I decided to use WatchDog Interrupt so that I can have 128 Bus clocks to analyse something, but unfortunately my WatchDog Interrupt code is not working.
I created a sample project separately to test watchdog interrupt, but it is not working, can anyone please help me, what I am doing wrong.

#include <stdint.h>

#include "isr.h"
#include "common.h"
#include "ics.h"
#include "sysinit.h"
#include "wdog.h"

int main()
{
volatile static uint8_t test;
WDOG_Feed();
test = 1;
WDOG_ConfigType sWDOGConfig = {0}; /*! < watchdog configuration structure */

/* Perform processor initialization */
NVIC_EnableIRQ( Watchdog_IRQn);
__enable_irq();
sysinit();
sWDOGConfig.sBits.bIntEnable = TRUE;
sWDOGConfig.sBits.bWaitEnable = FALSE;
sWDOGConfig.sBits.bStopEnable = FALSE;
sWDOGConfig.sBits.bDbgEnable = FALSE;
sWDOGConfig.sBits.bUpdateEnable = FALSE;
sWDOGConfig.sBits.bDisable = FALSE; /* enable WDOG */
sWDOGConfig.sBits.bClkSrc = WDOG_CLK_INTERNAL_1KHZ;
sWDOGConfig.u16TimeOut = 1000; /*< 1s */
sWDOGConfig.u16WinTime = 0;

WDOG_Init(&sWDOGConfig);

while(1)
{
if( test )
{
WDOG_Feed();
}
}
}

void WatchDog_ISR( void )
{
static uint8_t x;
x=0;
while(1)
{
x++;
}
}
void NMI_Isr(void)
{
/*!
* endless loop to generate watchdog reset
*/
while(1)
{
printf("Running in NMI_Isr()!\n");
}
}

I tried to use the code formatting, but unfortunately that doesn't work.

When i run the above code, it works properly without resetting, to stop watchdog refresh, test value is updated to "0" and due to this watchdog refresh or watchdog feed function will not get call, leading to system reset after 1 second. 

So my system is getting reset when I update the value of test to "0", but I want that before resetting Watchdog Interrupt shall be generated.

Please help me to identify what I am doing wrong.

Thanks in Advance

Tags (3)
1 Solution
5 Replies
1,771 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Not sure how do you check that the MCU didn't enter WatchDog_ISR.

Please clear a GPIO to 0V in WatchDog_ISR, and observe the voltage of that pin by using oscilloscope.
If the voltage will be 0V every n second, then the MCU has enter WatchDog_ISR.

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,771 Views
xpress_embedo
Contributor II

Thanks for your reply.

We can't test Watchdog, like I am doing, so I will use the method suggested by you.

By the I am doing this to track a problem and I am able to solve that problem, but still I will check this thing.

Thanks for your time.

0 Kudos
Reply
1,771 Views
xpress_embedo
Contributor II

Thanks for your reply.

Actually I put a breakpoints in the function "WatchDog_ISR" and let my system reset by WatchDog, unfortunately, it directly gets reset without in this ISR.

I will try your suggestion, but what's wrong with the method I am trying, can't we check this thing in debug mode, like I did by placing the breakpoints in WatchDog ISR.

0 Kudos
Reply
1,772 Views
mjbcswitzerland
Specialist V
1,771 Views
xpress_embedo
Contributor II

Thank You, I got my answer.

0 Kudos
Reply