"WDT_P4_Example01" Sample program issue

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.
SuRa_2245351
Level 4
Level 4
First like received First like given

 I am implementing "WDT_P4_Example01" sample program on PROC BLE and the program generates reset after 5 seconds and after power ON red LED turns ON for 200ms since reset is caused by the watchdog timer.

   

But when I make only one change to program i.e instead of "uint32 interruptCnt = 1u;" if I define it as "uint16 interruptCnt = 1u;" the reset is cause is not due to WDT and red LED doesn't turns ON for 200 ms.

   

I am using "CY8CKIT-042-BLE" kit with PROC BLE board. I had attached project with single modification as mentioned above please reply.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

   

Sorry for the inconvenience happened to you!!

   

When the WDT timer mode is configured as Watchdog(w/interrupt) [ PSoC Creator ,.cydwr file-> Clocks tab-> Edit Clock-> Low frequency Clock-> Timer0 Mode] and the WDT interrupt is not cleared, then the WDT interrupt will generate continuously at every LFCLK cycle.

   

So when we select a 32 bit variable (uint32 interruptCnt) it increments upto =< 2^32  in 0.5*3 seconds( WDT interrupt interval) . Means the condition "if (interruptCnt <= LED_BLINK_5_TIMES)" will not satisfy after uint32 interruptCnt=10 and WDT interrupt will not clear in 0.5*3=1.5 seconds and device will reset.

   

But  when we select a 16 bit variable (uint16 interruptCnt) it increments upto =< 2^16  in 0.5*3 seconds( WDT interrupt interval) and it might overflow and the  condition "if (interruptCnt <= LED_BLINK_5_TIMES)" will satisfy after uint16 interruptCnt<=10 again in 1.5 seconds and  WDT interrupt will clear in 0.5*3=1.5 seconds and device will not reset which is happening here.

   

To overcome this problem you can disable the WdtIsr after interruptCnt==11.

   

Please find the attached modified project attached with this response.

   

 

   

Regards,

   

Gyan

View solution in original post

0 Likes
3 Replies
lock attach
Attachments are accessible only for community members.
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

   

Sorry for the inconvenience happened to you!!

   

When the WDT timer mode is configured as Watchdog(w/interrupt) [ PSoC Creator ,.cydwr file-> Clocks tab-> Edit Clock-> Low frequency Clock-> Timer0 Mode] and the WDT interrupt is not cleared, then the WDT interrupt will generate continuously at every LFCLK cycle.

   

So when we select a 32 bit variable (uint32 interruptCnt) it increments upto =< 2^32  in 0.5*3 seconds( WDT interrupt interval) . Means the condition "if (interruptCnt <= LED_BLINK_5_TIMES)" will not satisfy after uint32 interruptCnt=10 and WDT interrupt will not clear in 0.5*3=1.5 seconds and device will reset.

   

But  when we select a 16 bit variable (uint16 interruptCnt) it increments upto =< 2^16  in 0.5*3 seconds( WDT interrupt interval) and it might overflow and the  condition "if (interruptCnt <= LED_BLINK_5_TIMES)" will satisfy after uint16 interruptCnt<=10 again in 1.5 seconds and  WDT interrupt will clear in 0.5*3=1.5 seconds and device will not reset which is happening here.

   

To overcome this problem you can disable the WdtIsr after interruptCnt==11.

   

Please find the attached modified project attached with this response.

   

 

   

Regards,

   

Gyan

0 Likes

Thank you for reply Gyan but I didn't understand your explanation.

0 Likes
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

   

  Hope the project worked fine for you.

   

" When the variable is declared as uint8 , it overflows and becomes '0' within the period (0.5*3) and when it becomes '0' the LED blink condition also becomes true,and it will continuously blinks rather the interrupt causing system 'RESET' ".

   

-Gyan