cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

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?

0 Likes
Reply
1 Solution
New Contributor II

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();

     

     .....
}

View solution in original post

0 Likes
Reply
1 Reply
New Contributor II

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();

     

     .....
}

View solution in original post

0 Likes
Reply