Wakeup takes very long time

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.
Anonymous
Not applicable

Hi, I am using CY8C4045AZI-S413 for my project.  In IDLE state machine, the code simply wakes up every 500ms and checks for proximity widget. The wired part is if I turn off the sleep feature, system state machine will transfer smoothly to Touched_State. If I turn sleep function on. It will take a  long time to transfer state machine.

static SUB_STATE main_idle_state(void){

    SUB_STATE sub_state = S_NONE;

    CAP_OUT_Write(1);

    VDD_LED_CTRL_Write(0);  

    memset(WORK_BUFFER, 0, WORK_BUFFER_LENGTH);

    bool is_btn_processed = true;

    while(sub_state == S_NONE){

        /* Scan all widgets */

        if(CapSense_NOT_BUSY == CapSense_IsBusy() && is_btn_processed == true){  

            CapSense_SetupWidget(CapSense_PROXIMITY0_WDGT_ID);

            CapSense_Scan();

            is_btn_processed = false;

        }

       

        /* If a wakeup command received from master... */

        if(WORK_BUFFER[0] == 0x5A){

            g_fast_scan_delay_counter = FAST_SCAN_DELAY;     

            g_watchdog_match_value = WDT_TIMEOUT_FAST_SCAN; 

            sub_state = S_MASTER_EVT;

            break;

        }

       

        if(CapSense_NOT_BUSY == CapSense_IsBusy() && is_btn_processed == false){

            CapSense_UpdateWidgetBaseline(CapSense_PROXIMITY0_WDGT_ID);

            CapSense_ProcessWidget(CapSense_PROXIMITY0_WDGT_ID);

            //if(CapSense_IsWidgetActive(CapSense_PROXIMITY0_WDGT_ID)){

            if(CapSense_IsProximitySensorActive(CapSense_PROXIMITY0_WDGT_ID,0)){

                /* Initialize fast scan delay counter */

                g_fast_scan_delay_counter = FAST_SCAN_DELAY;     

                g_watchdog_match_value = WDT_TIMEOUT_FAST_SCAN; 

                CAP_OUT_Write(0);

                sub_state = S_TOUCH_EVT;

                break;

            }

            is_btn_processed = true;

        }

        /* Put CPU to sleep.  When the WDT interrupt occurs, CPU will wakeup

        and perform the next scan */

#if  (POWER_SAVE_MODE != 0)

            if(sub_state == S_NONE){

                //CySysPmSleep();

                GotoSleep();

            }

#endif

    }/*while(sub_state == S_NONE)*/

    return sub_state;

}

0 Likes
5 Replies
Anonymous
Not applicable

Anyone can help look into this issue?

0 Likes
Anonymous
Not applicable

I believe the capsense does not run while the unit is in a power saving mode (like sleep, or deep sleep). My guess would be that the capsense you are waiting for a touch sense from is not being activated until after some other event wakes up the chip, upon which it quickly detects the touch and triggers your code. This might explain the delay being ~500ms corresponding with your proximity widget wakeup time?

0 Likes
Anonymous
Not applicable

Correct. My original plan is to wake up code by WDT timer every 500ms. Capsense starts to scan after waking up and in my configuration it will totally take 15ms to scan all widgets. So the whole time should be like less than 600ms. While In fact it takes like a couple of seconds to capture the proximity sensor.

0 Likes
Anonymous
Not applicable

Could it be that you are inadvertently putting the chip to sleep after each read of the capsense? Hence the long time to acquire a touch? (500ms wakeup, reads one sample of capsense, goes to sleep again, repeat)

I would verify that you are disabling the sleep mode until you finish reading the capsense; either by a count or time limit. Otherwise, if you are setting the device to a sleep power mode, and then the chip wakes up for the capsense reading, it could just be going right back to sleep without finishing reading the capsense debounce period.

0 Likes
Anonymous
Not applicable

Hi Pratt,  Thanks for your response. But can you explain this in detail?

  • "I would verify that you are disabling the sleep mode until you finish reading the capsense; either by a count or time limit. "
  • "it could just be going right back to sleep without finishing reading the capsense debounce period."
0 Likes