Wakeup from System Deep Sleep by WDT sometimes fails

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

cross mob
ChSa_3356871
Level 1
Level 1

Hello,

we were planning to put the System into Deep Sleep mode by calling Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT) on both CPUs. The system should then wake up after a short time using a WDT.

Most of the time this seems to work, and the status returned by Cy_SysPm_DeepSleep() is always CY_SYSPM_SUCCESS.

Sometimes though the system keeps hanging in deep sleep without waking up. We were able to resume it in such a case by attaching the debugger, after which the result status is still CY_SYSPM_SUCCESS.

The following piece of code is used to configure the WDT and put the CM4 into deepsleep (CM0 is in permanent Deep Sleep in the application):

    // configure the WDT interrupt

    cy_en_sysint_status_t sysint_status = Cy_SysInt_Init(&WDTIsr_cfg, WDTIsr);

    if(sysint_status != CY_SYSINT_SUCCESS) {

        mDEBUG_PRINTF("ISR ERROR\n");

    }

   

    NVIC_EnableIRQ(srss_interrupt_IRQn);

    Cy_WDT_Init();

    Cy_WDT_UnmaskInterrupt();

    Cy_WDT_SetIgnoreBits(4);

    Cy_WDT_Unlock();

    Cy_WDT_Enable();

    __enable_irq();

    cy_en_syspm_status_t status = Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);

    mDEBUG_PRINTF("Woke from DS with status: %X\n", status);

    Cy_WDT_Unlock();

    Cy_WDT_Disable();

    __NVIC_DisableIRQ(srss_interrupt_IRQn);

pastedImage_2.png

Thanks,

Christoph

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Christoper,

There are two things to consider. If you need periodic interrupt from watch dog timer the match register should be periodically updated in the ISR. Now another challenge is after wakeup from sleep, the match register value is automatically is in lock state(Locks out configuration changes to the Watchdog Timer register). So you have to call Cy_WDT_Unlock() API before updating the match register. I have attached one sample project where I have been able to generate the periodic match interrupt. This should be helpful. We will be updating our documents, so that this information will be obvious to you in future.

Best Regards,
VRS

View solution in original post

6 Replies

That was actually the code example I took as a reference.

I was wondering if there are any known issues regarding the wakeup from WDT.

One more thing I noticed was that while the Cy_WDT_SetIgnoreBits() seems to work as expected, Cy_WDT_SetMatch() doesn't seem to have any effect: The time to wakeup remains the same regardless of the setting.

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Christoph,

Could you please call Cy_SysLib_GetDeviceRevision() in your main.c and tell me the value you get back?

Best Regards,
VRS

0 Likes

Hi,

the value returned by Cy_SysLib_GetDeviceRevision() is 34 (decimal).

0 Likes
lock attach
Attachments are accessible only for community members.
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Christoper,

There are two things to consider. If you need periodic interrupt from watch dog timer the match register should be periodically updated in the ISR. Now another challenge is after wakeup from sleep, the match register value is automatically is in lock state(Locks out configuration changes to the Watchdog Timer register). So you have to call Cy_WDT_Unlock() API before updating the match register. I have attached one sample project where I have been able to generate the periodic match interrupt. This should be helpful. We will be updating our documents, so that this information will be obvious to you in future.

Best Regards,
VRS

Thanks for the explanation.

Seems to work after initial tests. We will see if that fixes our problem for good.

0 Likes