cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

moshc_4060821
New Contributor II

i am working with Psoc4 Ble pioneer kit.

i want to generate a WDT based interrupt after every hour. so to do that i have i have used global signal component.

this is my code

CY_ISR(WDT_ISR_handler)

{

    WDT_ISR_ClearPending();

}

int main(void)

 

    HW_Init();

   

    /* Starts RTC component */

    RTC_Start();

    /* Set RTC time update period */

    RTC_SetPeriod(1u, SYSTICK_EACH_1_HZ);

   

    RTC_ClearAlarmStatus() ;

    RTC_SetAlarmHandler( alarm_handler ) ;

    RTC_SetAlarmMask( RTC_ALARM_SEC_MASK ) ;

   

    WDT_ISR_StartEx(WDT_ISR_handler);

  

   

   

    for(;;)

    {

      

    }

}

please find attached screen shots for WDT2 clock configuration.(currently i am testing it with only 4 seconds)

so my problem is first time interrupt is generated after 4 seconds but then it could not clear and the pending register or something.

please guide me.

0 Likes
1 Solution
moshc_4060821
New Contributor II

hi

i have solved the problem.

this is my code.

    

CY_ISR(WDT_ISR_handler)

{

      CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER2_INT);

}

int main(void)

{

    HW_Init();

 

    /* Starts RTC component */

    RTC_Start();

    /* Set RTC time update period */

    RTC_SetPeriod(1u, SYSTICK_EACH_1_HZ);

 

    RTC_ClearAlarmStatus() ;

    RTC_SetAlarmHandler( alarm_handler ) ;

    RTC_SetAlarmMask( RTC_ALARM_SEC_MASK ) ;

     /* Enable WDT0 counter */

    CySysWdtEnable(CY_SYS_WDT_COUNTER2_MASK);   // WDT=PeriodicTimer

    WDT_ISR_StartEx(WDT_ISR_handler); // Start ISR for pin toggle

    CySysWdtEnable(CY_SYS_WDT_COUNTER2);

    for(;;)

    {

    

    }

}


thanks for helping.

Mohit

View solution in original post

0 Likes
3 Replies
odissey1
Honored Contributor II

mohit.shukla,

Check this WDT interrupt and initialization code. Project link

ButtonSw32: button switch debouncer component

/odisssey1

//============================================

// The interrupt handler for WDT counter 0 interrupts.

//============================================

CY_ISR(WdtIsrHandler)

{

    //WdtIsr_ClearPending(); // Clear Interrupt (not needed)

 

    #if(CY_IP_SRSSV2)

        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT); // Clear WDT0 interrupts state

    #else

        CySysWdtClearInterrupt();

    #endif

 

    Button_1_CheckStatus(); // poll Button_1

}

void Initialize(void)

{

    CyGlobalIntEnable; //enable global interrupts.

 

    /* Enable WDT0 counter */

    #if(CY_IP_SRSSV2)

        CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);   // WDT=PeriodicTimer

    #else

        CySysWdtEnable();

        CySysWdtUnmaskInterrupt();                  // WDT=Watchdog

    #endif

 

    WdtIsr_StartEx(WdtIsrHandler); // Start ISR for pin toggle

   //....

}

int main()

{

    Initialize();

    for(;;)

    {

         //....

     }

}

pastedImage_0.png

0 Likes
moshc_4060821
New Contributor II

hi odisssey1

thanks for your reply.

but it still doesn't work.

i have configured clock WDT2 to generate 4 seconds interval using WCO:WDT Issue.png 

and this is my code.

CY_ISR(WDT_ISR_handler)

{

//WdtIsr_ClearPending(); // Clear Interrupt (not needed)

    #if(CY_IP_SRSSV2)

        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT); // Clear WDT0 interrupts state

    #else

        CySysWdtClearInterrupt();

    #endif

}

int main(void)

{

    HW_Init();

  

    /* Starts RTC component */

    RTC_Start();

    /* Set RTC time update period */

    RTC_SetPeriod(1u, SYSTICK_EACH_1_HZ);

  

    RTC_ClearAlarmStatus() ;

    RTC_SetAlarmHandler( alarm_handler ) ;

    RTC_SetAlarmMask( RTC_ALARM_SEC_MASK ) ;

    /* Enable WDT0 counter */

    #if(CY_IP_SRSSV2)

        CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);   // WDT=PeriodicTimer

    #else

        CySysWdtEnable();

        CySysWdtUnmaskInterrupt();                  // WDT=Watchdog

    #endif

    WDT_ISR_StartEx(WDT_ISR_handler);

 

  

  

    for(;;)

    {

     

    }

}

and i have put a break point in ISR function...first time interrupt generated after 4 second but then it it is generating continuously.

please help...

0 Likes
moshc_4060821
New Contributor II

hi

i have solved the problem.

this is my code.

    

CY_ISR(WDT_ISR_handler)

{

      CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER2_INT);

}

int main(void)

{

    HW_Init();

 

    /* Starts RTC component */

    RTC_Start();

    /* Set RTC time update period */

    RTC_SetPeriod(1u, SYSTICK_EACH_1_HZ);

 

    RTC_ClearAlarmStatus() ;

    RTC_SetAlarmHandler( alarm_handler ) ;

    RTC_SetAlarmMask( RTC_ALARM_SEC_MASK ) ;

     /* Enable WDT0 counter */

    CySysWdtEnable(CY_SYS_WDT_COUNTER2_MASK);   // WDT=PeriodicTimer

    WDT_ISR_StartEx(WDT_ISR_handler); // Start ISR for pin toggle

    CySysWdtEnable(CY_SYS_WDT_COUNTER2);

    for(;;)

    {

    

    }

}


thanks for helping.

Mohit

View solution in original post

0 Likes