Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
bugkiller
Level 2
Level 2
10 replies posted 50 sign-ins First like received

I recently study about WDT(Watchdog timer), and i find out because of the 32.768kHz crystal, it can be used for up to 2 seconds Max. After some research,  I just found by using <CySysWdtSetCascade> function(cascade 2 different 'periodic timer source'), can expand Watchdog time more than 2 second.  

It works perfect for longer WDT Deep sleep function, but I want to apply this Cacade function to WDT reset . 

(source : https://iotexpert.com/psoc-4200m-wdt-long-deep-sleep/)

bugkiller_2-1666660682339.png

<periodic timer >

 

Here's what I want to do:

bugkiller_1-1666660608484.png

1. Blink Blue LED about 10 second.

2. When Watchdog timer is done, Blue LED shuts off, system goes to reset, Red LED light is on.

my current code below:

#include "project.h"
/*
void wdtCallback()
{
  LED_RED_Write( ~LED_RED_Read() );
  //blink LED for every 10 seconds
}
*/
int main(void)
{
  CyGlobalIntEnable; /* Enable global interrupts. */
  CySysWdtSetCascade(CY_SYS_WDT_CASCADE_01);

if(CySysGetResetReason(CY_SYS_RESET_WDT) == CY_SYS_RESET_WDT )
{
  CySysWdtDisable(CySysWdtGetCascade());
  LED_RED_Write(0); // turn on the red LED
  while(1); // hang
}


for(;;)
{
  LED_BLUE_Write(~LED_BLUE_Read());
  CyDelay(200);
}
}

Thanks!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @bugkiller ,

Please take a look at PSoC 4 Watchdog Timer code example. Here WDT0 and WDT1 are cascaded. The match event on WDT1 resets the device. The values used in the code example are :

WDT0 is configured in CY_SYS_WDT_MODE_INT mode [WDT_MODE0 = 01]. Match value on WDT0 = 0x5000 = 20480 [this becomes the prescaler value]. Hence the input frequency for WDT1 is 

ILO/WDT0_match = 32.768kHz/20480 = 1.6Hz

WDT0 is configured in CY_SYS_WDT_MODE_RESET mode [WDT_MODE0 = 10]. Match value on WDT1 is 0x09. Hence a reset is generated every 5.625s

1.6Hz/9 = 0.1778Hz
Reset occurs every = 1/f = 1/0.1778 = 5.625s

 

Now, to generate 10s delay using WDT: WDT0_match = 0xFFFF and WDT1_match = 0x05.

I have modified the code example with your code, and I could achieve the required functionality. Find the archive file attached.

Regards,
Nikhil

View solution in original post

2 Replies
lock attach
Attachments are accessible only for community members.
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @bugkiller ,

Please take a look at PSoC 4 Watchdog Timer code example. Here WDT0 and WDT1 are cascaded. The match event on WDT1 resets the device. The values used in the code example are :

WDT0 is configured in CY_SYS_WDT_MODE_INT mode [WDT_MODE0 = 01]. Match value on WDT0 = 0x5000 = 20480 [this becomes the prescaler value]. Hence the input frequency for WDT1 is 

ILO/WDT0_match = 32.768kHz/20480 = 1.6Hz

WDT0 is configured in CY_SYS_WDT_MODE_RESET mode [WDT_MODE0 = 10]. Match value on WDT1 is 0x09. Hence a reset is generated every 5.625s

1.6Hz/9 = 0.1778Hz
Reset occurs every = 1/f = 1/0.1778 = 5.625s

 

Now, to generate 10s delay using WDT: WDT0_match = 0xFFFF and WDT1_match = 0x05.

I have modified the code example with your code, and I could achieve the required functionality. Find the archive file attached.

Regards,
Nikhil

bugkiller
Level 2
Level 2
10 replies posted 50 sign-ins First like received

Many thanks! It helped a lot to solve my problem.

0 Likes