Cypress技术论坛
直播中

余婧

7年用户 138经验值
私信 关注
[问答]

唤醒需要很长时间

你好,我正在使用CY8C4045 AZI S413进行我的项目。在空闲状态机中,代码只需每500毫秒唤醒一次,并检查邻近控件。有线部分是,如果我关闭睡眠功能,系统状态机将顺利转移到ToucEdEl状态。如果我打开睡眠功能。传输状态机需要很长时间。
静态子状态MeNeIDIDLE状态(空隙){
子状态子状态= SnNO;
CAPIA Outlook编写(1);
VDDyLeDyCtRLX编写(0);
MeMSET(Word缓冲区,0,WorkBuffell长度);
BoOL ISH-BTNYROMPULTE= TRUE;
而(子状态= = sn-无){
*扫描所有小部件*/
如果(CopsSeNeNothLoad==CAPENSESEIISBYY());
CAPENSESEA SETUP WIDGET(CAPENSESEA OUtiQUITY 0XWDGTZID);
CAPENSESEA扫描();
ISSB处理= FALSE;
}
/*如果唤醒命令从主机接收…*/
如果(Word缓冲区〔0〕=0x5a){
G.FASTHEXSCALL DELAYY计数器= FASTH扫描延迟;
GyAdvEddoxMatCHyValue= WDTTyTimeOutFASTHySCAN;
子状态= S.Mistalay-EVT;
断裂;
}
如果(CopsSeNeNothLoad==CAPENSESEIISBYY());
CAPENSESEIUPDATEWIDGETBASIC(CAPENSESEA OULIDITY 0WDGTGYID);
CAPSENSEA进程WIGGET(CAPENSESEA近邻0WDGTGID);
//If(CopsSeNeISWIDGETAcIcd(CopsSeNeRealthIy00WDGTGYID)){
如果(CopsSeNeSeNesithEnristor Actu能能能为量(CAPENSESEIONTIONITY 0WDGTGID,0))
*初始化快速扫描延迟计数器**
G.FASTHEXSCALL DELAYY计数器= FASTH扫描延迟;
GyAdvEddoxMatCHyValue= WDTTyTimeOutFASTHySCAN;
CAPIA Outlook编写(0);
子状态= SO TouChyEVT;
断裂;
}
ISSB处理=真;
}
*将CPU置于睡眠状态。当WDT中断发生时,CPU将唤醒。
并执行下一次扫描*/
(如果)= 0)
如果(子状态==Sn-无){
//CysYSPMLeSEP();
GoToScript();
}
第二节
} /*同时(子状态= = sn-无)*/
返回子状态;
}
E-LoC.CyWrk.CaseV01.Zip
674.4 K

以上来自于百度翻译


     以下为原文
  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;
}


回帖(4)

黎歆俭

2019-1-3 14:54:34
我相信当单元处于省电模式(如睡眠或深度睡眠)时,CAPSENSE不会运行。我的猜测是,你正在等待一个触摸感的CAPSENSE是不被激活,直到其他一些事件唤醒芯片后,它很快检测到触摸并触发你的代码。这可能解释了延迟为-500毫秒对应于您的临近窗口唤醒时间?

以上来自于百度翻译


     以下为原文
  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?
举报

余婧

2019-1-3 15:00:21
对的。我最初的计划是每500毫秒用WDT定时器唤醒代码。CASESENSE在醒来后开始扫描,在我的配置中,它将花费15ms扫描所有的小部件。所以整个时间应该小于600毫秒,而事实上需要几秒钟的时间来捕捉接近传感器。

以上来自于百度翻译


     以下为原文
  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.
举报

黎歆俭

2019-1-3 15:15:39
是不是每次读卡彭斯之后,你都会不经意地把芯片放在睡眠中?因此,获得触摸的时间长了吗?(500毫秒唤醒,读取一个样本的CasSoC,再次入睡,重复)
我将验证您禁用睡眠模式,直到您读完CAPSENSE;或者通过计数或时间限制。否则,如果您将设备设置为休眠电源模式,然后芯片唤醒CAPSENSE读取,它可能只是在没有读完CAPSENSE反跳周期的情况下马上回到睡眠状态。

以上来自于百度翻译


     以下为原文
  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.
举报

余婧

2019-1-3 15:34:57
嗨,普拉特,谢谢你的回复。但你能详细解释一下吗?
“我会验证你正在禁用睡眠模式,直到你读完CAPSENSE,要么通过计数或时间限制。”它可能只是在没有读完CopSoad反跳周期的情况下马上回到睡眠状态。

以上来自于百度翻译


     以下为原文
  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."
举报

更多回帖

发帖
×
20
完善资料,
赚取积分