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

cross mob
lock attach
Attachments are accessible only for community members.
Manoj_Kumar
Level 3
Level 3
50 sign-ins 25 replies posted 10 questions asked

I am trying to check if wdt reset works, but unfortunately its not. In the code am blinking blue led (P7_3) whenever a reset occurs because of user reset, orange led should blink whenever the wdt reset occures, green led is toggling indicating the program is running. So am calling cyhal_wdt_kick() in the loop, so everytime kick works the wdt should reset the program and orange led should blink 2 times and then green led should start glowing.

So the scenarios are:

1. if user press reset button then blue led should blink 2 times.

2. If cyhal_wdt_kick() works then orange led should blink 2 times.

3. green led indicate the flow of program.

In my case the orange led never blink, which indicate that wdt is never resetting the program. And i want it to reset every 5 seconds.

I am using CY8C624ABZI-S2D44 BSP.

I don't want any interrupt or anything, i just want wdt to just reboot everything.

0 Likes
1 Solution
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @Manoj_Kumar , 

Your WDT will not reset the device since the cyhal_wdt_kick(&wdt_obj) is always executed in a for-loop. 
That function will prevent the WDT to reach the timeout and reset will not occur.
From your code, there is a flag ( macro )defined 

#define ENABLE_BLOCKING_FUNCTION            0

It will have an impact on which part of the code the compiler will compile

#if (ENABLE_BLOCKING_FUNCTION)
     while(1);
#else
    /* Reset WDT */
    cyhal_wdt_kick(&wdt_obj);
   /* Constant delay of 1000ms */
   cyhal_system_delay_ms(1000);
   /* Invert the state of LED */
   cyhal_gpio_toggle(P0_5);
#endif

if you set the macro with 1 => #define ENABLE_BLOCKING_FUNCTION 1 compiler will compile the code between #if and #else and ignoring the codes between the #else - #endif part. Then the function cyhal_wdt_kick() will not be executed and your WDT can reach the timeout causing your device reset.

Warm regards

Andri

View solution in original post

2 Replies
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @Manoj_Kumar , 

Your WDT will not reset the device since the cyhal_wdt_kick(&wdt_obj) is always executed in a for-loop. 
That function will prevent the WDT to reach the timeout and reset will not occur.
From your code, there is a flag ( macro )defined 

#define ENABLE_BLOCKING_FUNCTION            0

It will have an impact on which part of the code the compiler will compile

#if (ENABLE_BLOCKING_FUNCTION)
     while(1);
#else
    /* Reset WDT */
    cyhal_wdt_kick(&wdt_obj);
   /* Constant delay of 1000ms */
   cyhal_system_delay_ms(1000);
   /* Invert the state of LED */
   cyhal_gpio_toggle(P0_5);
#endif

if you set the macro with 1 => #define ENABLE_BLOCKING_FUNCTION 1 compiler will compile the code between #if and #else and ignoring the codes between the #else - #endif part. Then the function cyhal_wdt_kick() will not be executed and your WDT can reach the timeout causing your device reset.

Warm regards

Andri

Thanks  for response,it worked.

0 Likes