You are here

PSoC 5 Battery Measurements | Cypress Semiconductor

PSoC 5 Battery Measurements

Summary: 3 Replies, Latest post by Bob Marlowe on 29 Oct 2015 08:56 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
ngohara's picture
36 posts


In the  past, I've used the PSoC 4 BLE battery measure example to make battery measurements on a device.


I am now trying to do the same for a new project, using the PSoC 5lp.

However, since there is no example, I am struggling to all of the necessary features.


First off, the PSoC 4 has an external pin labeled VREF that is used for this.  Would one of the VCCD pins be the PSoC 5 equivalent?


2ndly, there is a visible change in the macros for the PSoC 4 SAR ADC and the PSoC 5 SAR adc. 

I am struggeling to convert the following macros:




The macros and control registers seem to be different between the PSoC 4 and PSoC 5, which makes sense, I'm just struggeling to conver them.

Any help or advice is appreciated.


The following is the entire code piece I am trying to convert:

/* Set the reference to VBG and enable reference bypass */
        sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;

        /* 25 ms delay for reference capacitor to charge */
        /* Set the reference to VDD and disable reference bypass */
        sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;
        ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_VDDA;

        /* Perform a measurement. Store this value in Vref. */

        adcResult = ADC_GetResult16();
        /* Calculate input voltage by using ratio of ADC counts from reference
        *  and ADC Full Scale counts.
        mvolts = (1.024 * 2048) / adcResult;



user_242978793's picture
969 posts

Here is a program that measures up to 6 volts. It could be modified to measure higher voltages with resistor dividers.

ngohara's picture
36 posts

Is the ADC_DelSig_1_CountsTo_mVolts()   actually trusted to be relatively accurate,  assuming the VCC decreases as a battery drains?


Thanks for the advice.


user_1377889's picture
9294 posts

It all depends on your selected reference voltage. Most precise would be an internal ref (buffered). Might require do divide with R/R network the battery voltage. Have a look into the specs of the ADC, the accuracy is defined over the whole voltage range.



Log in to post new comments.