9 Replies Latest reply on Feb 11, 2016 9:22 PM by azheng1023_1510621

    Measuring CR-2032 Voltage

    azheng1023_1510621

      We followed the BLE_Battery_Level example project available with PSoC Creator closely. We have also looked at the excellent blog on this topic (http://www.cypress.com/blog/psoc-hacker-blog/measuring-vdd-battery-volts-psoc4). But I am not getting correct battery measurements. We are using CYBLE-022001-00 on our board and placed an 1uF capacitor between the ground and P0[5]. I am not able to paste the schematic here but attach the file.

         

      I am using the following firmware to measure VDD:

         

            int16 adcResult;

         

            int32 mvolts;

         

            uint32 sarControlReg;

         

            ADC_Start();

         

            sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;

         

            ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_INTERNAL1024BYPASSED;

         

            CyDelay(25);            

         

            sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;

         

            ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_VDDA;

         

            CyDelay(1);

         

            ADC_StartConvert();

         

            ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

         

            adcResult = ADC_GetResult16(ADC_BATTERY_CHANNEL);

         

            mvolts = (1024 * 2047) / adcResult;

         

      I am getting adcResults close to 0 (-20 to 5 in my tests). What am I doing wrong?

         

      Thanks.

         

      Alex