7 Replies Latest reply on May 8, 2019 5:39 AM by nkin_2927171

    CapSense CSD[v2.60] to CapSense [v5.0]

    nkin_2927171

      IC : CY8C4245AXI-483

       

      for testing i take 2 capsense and 4 led,

      toggle LED when I touch.

      if i use CapSence CSD [v2.60] then all work fine.

       

      #include "project.h"

      unsigned char status=0,flag[10];

      int main(void)

      {

          CyGlobalIntEnable;  

          OF_01_Write(1);OF_02_Write(1);                                                 //white led on  

          CapSense_Start();

          CapSense_InitializeAllBaselines();  

          for(;;)

          {

              CapSense_UpdateEnabledBaselines();

              CapSense_ScanEnabledWidgets();

              while(CapSense_IsBusy());      

              status=CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON01__BTN);

              if(status==1)

              {

                  if(flag[1]==0)  {flag[1]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

                  else            {flag[1]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

                  while(status==1)

                  {

                      CapSense_UpdateEnabledBaselines();

                      CapSense_ScanEnabledWidgets();

                      while(CapSense_IsBusy());   

                      status = CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON01__BTN);

                  }

              }

              status=CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON02__BTN);

              if(status==1)

              {

                  if(flag[2]==0)  {flag[2]=1;ON_02_Write(1);OF_02_Write(0);CyDelay(2);}

                  else            {flag[2]=0;ON_02_Write(0);OF_02_Write(1);CyDelay(2);}

                  while(status==1)

                  {

                      CapSense_UpdateEnabledBaselines();

                      CapSense_ScanEnabledWidgets();

                      while(CapSense_IsBusy());

                      status = CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON02__BTN);

                  }

              }      

          }

      }

       

      all work fine in above code (both touch button work )

       

      now i replace CapSense CSD[v2.60] to CapSense [v5.0]

      and i change API as per migration guide.

       

      #include "project.h"

      unsigned char status=0,flag[10];

      int main(void)

      {

          CyGlobalIntEnable;

        

          OF_01_Write(1);OF_02_Write(1);

        

          CapSense_Start();

          CapSense_InitializeAllBaselines();

        

          for(;;)

          {

              //CapSense_ClearSensors();

              CapSense_ProcessAllWidgets();

              CapSense_ScanAllWidgets();

              while(CapSense_IsBusy());

            

              status=CapSense_IsWidgetActive(CapSense_BUTTON01_WDGT_ID);

              if(status==1)

              {

                  if(flag[1]==0)  {flag[1]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

                  else            {flag[1]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

                  while(status==1)

                  {

                      CapSense_ProcessAllWidgets();

                      CapSense_ScanAllWidgets();

                      while(CapSense_IsBusy());   

                      status = CapSense_IsWidgetActive(CapSense_BUTTON01_WDGT_ID);

                  }

              }

            

              status=CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID);

              if(status==1)

              {

                  if(flag[2]==0)  {flag[2]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

                  else            {flag[2]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

                  while(status==1)

                  {

                      CapSense_ProcessAllWidgets();

                      CapSense_ScanAllWidgets();

                      while(CapSense_IsBusy());   

                      status = CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID);

                  }

              }

            

          }

      }

       

      In both code same pins are take for capsnese and leds.

      but Only 1st button working,2nd not working.(in CapSense [v5.0])

      what's i am doing wrong ?any one help me ?

      both code is attached.