2 Replies Latest reply on Jan 29, 2019 1:52 AM by wagu_1442321

    关于PSOC4000 多个gang sensor 的低功耗操作

    wagu_1442321

      hi,手头一触摸低功耗项目,共6个按键,其中5个离得较近,第六个较远,大约10多cm。担心1个gang sensor绑定6个sensor 信号质量不好。在参考CE210290代码基础上,打算慢速扫描的时候,弄成2个gang sensor。第一个级联1-5个,第二个级联单独的第六个pad。由于函数不能同时使用两个gang sensor,现在是每隔100ms的间隔,轮训扫描2个gang sensor,初步测试发现,功能正常可以唤醒。唯一的功耗不太正常。系统第一次进入低功耗唤醒用那个gang senor,那个唤醒和再次睡眠功耗正常,另一个个gang sensor功耗都30多ua了,调试多次也如此,希望大家做过多个gang senor的提供下建议。谢谢!以下是main函数:

       

         unsigned int i=0;

          for(i=0;i<100;i++) Delay(6000);

          CyGlobalIntEnable;       /* Enable Global Interrupt */

         

          #if TUNING_ENABLE

          {

              EZI2C_Start();  /* Set up communication and initialize data buffer to CapSense datastructure to use Tuner application */

              EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam),sizeof(CapSense_dsRam),(uint8_t *)&CapSense_dsRam);

              CapSense_Start();                       /* Start CapSense Component */

              CapSense_ScanAllWidgets(); /* Scan all widgets */

              for(;;)

              {

                  if(CapSense_NOT_BUSY == CapSense_IsBusy())   /* Do this only when a scan is done */

                  {

                      CapSense_ProcessAllWidgets();   /* Process all widgets */

                      CapSense_RunTuner();            /* To sync with Tuner application */

                      CapSense_ScanAllWidgets();      /* Start next scan */

                  }

              }

          }   

          #else

          {

       

       

              CyGlobalIntEnable;  

              EZI2C_EzI2CSetBuffer1(BUFFER_SIZE, READ_ONLY_OFFSET, ezI2cBuffer);    /* Setup buffer and start EZI2C slave (SCB mode) */

              EZI2C_Start();

          CapSense_Start();

              CapSense_SetupWidget(CapSense_BUTTON_WDGT_ID);

              WDT_Start();

       

       

              for(;;)

              { 

              /* Switch between sensor-scan -> wait-for-scan -> process -> sleep states */

                  switch(currentState)

                  {

                      case SENSOR_SCAN:                

                          /* Initiate new scan only if the CapSense hardware is idle */

                          if(CapSense_NOT_BUSY == CapSense_IsBusy())

                          {  

                              if(deviceScanMode == FAST_SCAN_MODE)

                              {

                                  CapSense_CSDScan();

                              }

                              else

                              {

                                  CapSense_CSDScanExt();

                              }

                              currentState = WAIT_FOR_SCAN_COMPLETE;                   

                          }

                          break;

       

       

                      case WAIT_FOR_SCAN_COMPLETE:

                          interruptState = CyEnterCriticalSection();

                          if(CapSense_NOT_BUSY != CapSense_IsBusy())

                          {

                              CySysPmSleep();

                          }

                          else

                          {

                              currentState = PROCESS_DATA;

                          }

                          CyExitCriticalSection(interruptState);

                          break;

                 

                      case PROCESS_DATA:

                          currentState = SLEEP;

                          buttonStatus = CLEAR;

                          if(deviceScanMode == FAST_SCAN_MODE)

                          {

                              CapSense_ProcessWidgetExt(CapSense_BUTTON_WDGT_ID, CapSense_PROCESS_CUSTOM);

                              if(CapSense_IsWidgetActive(CapSense_BUTTON_WDGT_ID))

                  {

                                  buttonStatus = CapSense_dsRam.snsStatus[CapSense_BUTTON_WDGT_ID];                       

                     softCounter = RESET;

                                  if((EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY)==0)

                                  {

                                      EZI2C_DisableInt();

                                      ezI2cBuffer[0] =  0xA5;

                                      ezI2cBuffer[1] =  ((buttonStatus & 0xFF00) >> 8);

                                      ezI2cBuffer[2] =  (buttonStatus & 0x00FF);

                                      EZI2C_EnableInt();

                                  }

                                  Touch_Int_Write(1);

                  }

                  else

                  {

                                  if((EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY)==0)

                                  {

                                      EZI2C_DisableInt();

                                      ezI2cBuffer[0] =  0x5A;

                                      ezI2cBuffer[1] =  0x00;

                                      ezI2cBuffer[2] =  0x00;

                                      EZI2C_EnableInt();

                                  }

                                

                                  Touch_Int_Write(0);

                     softCounter++; 

                                  if(softCounter >= SCANMODE_TIMEOUT_VALUE)

                                  {  

                         watchdogMatchValue = WDT_TIMEOUT_SLOW_SCAN;

                                      deviceScanMode = SLOW_SCAN_MODE;

                                      TurnSlowScanFlg = 1;

                                      CapSense_CSDSetupWidgetExt(CapSense_GANGEDBUTTON2_WDGT_ID, CapSense_GANGEDBUTTON2_SNS0_ID);

                                  } 

                              }

                          }    

                          else

                          {  

                              if(TurnSlowScanFlg == 0)

                              {

                                  TurnSlowScanFlg = 1;

                                  CapSense_ProcessWidget(CapSense_GANGEDBUTTON_WDGT_ID);

                                 

                                  //CapSense_SsCSDDisconnectSnsExt(CapSense_GANGEDBUTTON_WDGT_ID, CapSense_GANGEDBUTTON_SNS0_ID);

                                  //CapSense_SsCSDConnectSensorExt(CapSense_GANGEDBUTTON2_WDGT_ID, CapSense_GANGEDBUTTON2_SNS0_ID);

                                 

                                  CapSense_CSDSetupWidgetExt(CapSense_GANGEDBUTTON2_WDGT_ID, CapSense_GANGEDBUTTON2_SNS0_ID);

                              }

                              else

                              {

                                  TurnSlowScanFlg = 0;

                                  CapSense_ProcessWidget(CapSense_GANGEDBUTTON2_WDGT_ID);

                                  //CapSense_SsCSDDisconnectSnsExt(CapSense_GANGEDBUTTON2_WDGT_ID, CapSense_GANGEDBUTTON2_SNS0_ID);

                                  //CapSense_SsCSDConnectSensorExt(CapSense_GANGEDBUTTON_WDGT_ID, CapSense_GANGEDBUTTON_SNS0_ID);

                                 

                                  CapSense_CSDSetupWidgetExt(CapSense_GANGEDBUTTON_WDGT_ID, CapSense_GANGEDBUTTON_SNS0_ID);

                              }

                              if((CapSense_IsWidgetActive(CapSense_GANGEDBUTTON_WDGT_ID))||(CapSense_IsWidgetActive(CapSense_GANGEDBUTTON2_WDGT_ID)))

                              {

                                  currentState = SENSOR_SCAN;

                     watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;     

                                  deviceScanMode = FAST_SCAN_MODE;

                                  CapSense_SetupWidget(CapSense_BUTTON_WDGT_ID);

                              }

                          }

                          break;

                     

                      case SLEEP:            

       

       

                          if(deviceScanMode == FAST_SCAN_MODE)

                          {  

                              CySysPmSleep();

                          }

                          else

                          {

                              EnterDeepSleepLowPowerMode();

                          }

                          if(wdtInterruptOccured)

                          {

                              currentState = SENSOR_SCAN;

                              wdtInterruptOccured = FALSE; 

                              CalibrateWdtMatchValue();

                          }

                      break;

                     

                      default:

                          CYASSERT(0);

                      break;

                  }

              }

         

          }

          #endif

      }

        • 1. Re: 关于PSOC4000 多个gang sensor 的低功耗操作
          LinglingG_46

          首先: 如果6个按键绑定在一起扫描的话,你是遇到什么问题了吗?

          下面我的讨论将你前五个绑定在一起的sensor 称为SENSOR0, 第六个sensor称为SENSOR1

          第一,我认为你没有必要分成两个部分来扫,这样会让原来简单的逻辑变得复杂。

          第二,如果你要分成两个按键来判断当前系统是否要进入全速扫描的状态,我觉得你可以按照扫描SENSOR0,如果SENSOE0 active,直接让程序进入全速扫描的状态。 如果SENSOR0不是active的,直接再扫SENSOR1,不需要隔100ms扫一个。如果你隔100ms扫一个sensor, 有可能在扫SENSOR0的时候SENSOR1是处于active的状态。

          总而言之, 我还是觉得你直接扫描6senor是比较合理的。

          • 2. Re: 关于PSOC4000 多个gang sensor 的低功耗操作
            wagu_1442321

            谢谢。这个问题已经解决了。