WDT (Watchdog Timer) sample program1 for PSoC4

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.
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Goal: Try to create a very simple WDT sample using one WDT.

Hi,

I have to take medicine every morning because I had been over weight for years. However, as I get used to taking medicine every day, I sometime forget to take it. In order to prevent this, I am thinking of programming to make it known by lighting the LED at a certain fixed time. I studied the Deep Sleep function to make it battery-powered and have a long life. I will introduce the program created at that time.

 The environment used is as follows:

・PSoC Creator 4.4

・CY8CKIT-042-BLE-A

 

Program behavior:

 The CPU wakes up every 500mS and toggles the LED. After the initial setting (WDT setting), the CPU will be Deep l Sleep. The WDT interrupt wakes up the CPU and processes the LED, goes in Deep Sleep. The purpose is to significantly reduce CPU consumption.

First of all, check the operation by copying and improving what other people made. I referred to the following.

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

 

The WDT has three timers and is supplied by LFCLK. This time, the purpose is to check the operation with the simplest program, so WDT_INT0 is used to perform WakeUp and interrupt operations using only WDT0.

1.png

 

The circuit is simply the setting of the LED part as shown below.

2.pngPin map for CY8CKIT-042-BLE-A is as below.

 3.png

 

WDT is set by the configure System clocks in PSoC Creator, so I set it as follows. WDT0 Check to enable and set Divider to 1600.

 4.png

 

The program is simple. When the time comes in the WDT, an interrupt is input to the CPU and Wakup is performed, the LED is toggled by interrupt processing, and Deep Sleep in the for loop is executed when the interrupt processing is completed.

 

#include "project.h"

 

void wdtCallback()

{

    LED_Write(~LED_Read());   

}

 

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    CySysWdtSetInterruptCallback(CY_SYS_WDT_COUNTER0,wdtCallback);

   

    for(;;)

    {

        CySysPmDeepSleep();

    }

}

 

Thanks,
Kenshow

0 Likes
0 Replies