1 Reply Latest reply on Sep 21, 2018 2:31 PM by user_493190902

    Is it possible to change the CapSense resolution at run-time?

    mike_young_3688726

      I have already developed firmware that uses 16-bit, but now I need higher sampling rate so 14-bit is used.  I would like to keep one firmware that can work with either.  Is it possible to modify the resolution at run-time?

        • 1. Re: Is it possible to change the CapSense resolution at run-time?
          user_493190902

          I am unable to test this at this time, but you may be able to do this in the following way. I have done something similar before to change current DAC settings at run time.

           

          //From CapSense_1.h

          extern uint8 CapSense_1_widgetResolution[];

           

          void change_resolution(uint8 sensor, uint8 resolution)
          {

               switch (resolution)
               {

           

               case 10:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_10_BITS;

               break;

               case 11:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_11_BITS;

               break;

               case 12:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_12_BITS;

               break;

               case 13:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_13_BITS;

               break;

               case 14:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_14_BITS;

               break;

               case 15:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_15_BITS;

               break;

               case 16:

                   CapSense_1_widgetResolution[sensor] = CapSense_1_PWM_RESOLUTION_16_BITS;

               break;

               default:

               break;


               }

           

               CapSense_1_SetScanSlotSettings(sensor);

               CyDelay(10);


          }

           

          int main()
          {

               change_resolution(0, 12) //Change first sensor resolution to 12

               CapSense_1_Start();

               

               .....
          }