1 of 1 people found this helpful
You missed setting up the interrupt handler:
WDT_ISR_StartEx(WDT_Int_Handler);//setup WDT interrupt ISR
Otherwise, the unhandled interrupt will cause the CPU to lock into a NOP loop (default int handler or some other name)
Thanks for the quick response.
I am not using any interrupt handler. And I am not sure why this is required.
My understanding is:
- enabling the WDT in reset on match mode will reset the cpu once counter reaches the match value
- the main function continuously resets the counter to 0
- if main function hangs, the WDT will reset the cpu
I do not see where the interrupt handler is required.
Please could you explain about the purpose of ISR in watch dog timer and also how to implement it.
Hmmmm; If you are using it as a reset on reaching the match value, and are continuously resetting it, then I would agree with you that it should work.
The WDT can also be used as a generic timer, that runs a function/code upon reaching the matching value.
Thus, you need to start the WDT using the WDT_ISR_StartEx(Int_Handler) with the Int_Handler being the address of the function to run upon the timer interrupting. (You would then handle clearing the interrupt flag, and/or doing other code)
I misunderstood that you didn't want to use it as a timer for firing cleanup code or shutdown/restart code
Going back to your use/method: The CySysWdtResetCounters() function requires you to unlock and lock the WDT before and after changing values/resetting the cound. This mitigates program code running WDT reset code by accident from random address jumping without first running the unlock sequence beforehand. The document describing WDT usage and notes: http://www.cypress.com/file/233616/download
Looking at your code, it should be working as is I think.
You could try running the unit with a debugger, and set up an interrupt to see if the WDT is firing an interrupt, or if the program is crashing before it reaches the WDT reset function(s).
I think the issue might be more towards something else than your code;
If you attach an archive of your project, we can all look at your settings and give more information hopefully