- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
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:
ADC_VREF_INTERNAL1024BYPASSED
ADC_VREF_VDDA
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;
ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_INTERNAL1024BYPASSED;
/* 25 ms delay for reference capacitor to charge */
CyDelay(25);
/* 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. */
CyDelay(1);
ADC_StartConvert();
ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
adcResult = ADC_GetResult16();
/* Calculate input voltage by using ratio of ADC counts from reference
* and ADC Full Scale counts.
*/
mvolts = (1.024 * 2048) / adcResult;
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob