- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a project with an ADC wired as follows:
and configured as follows:
VDDA is 3.3V. When I feed a voltage of 2.00V into VBatIn, I get a result of approximately 430 counts, which comes out to approximately 1.4V. The behaviour is the same if I buffer the signal internally with an Opamp component.
Is something misconfigured here? What do I need to do to get the right values coming out of the ADC?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you tried to use ADC_CountsTo_mVolts() function?
I tried the following using CY8CKIT-062-WIFI-BT (CY8C6247BZI-D54ES on board)
(1) Schematic
(2) ADC Config
Note: Although I tried to duplicate your config, I noticed that the "Scan duration" is quite different from yours.
(3) Pin assign
(4) main.c
====================
#include "project.h"
#include "stdio.h"
#define STR_LEN 128
char str[STR_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
void init_hardware(void)
{
__enable_irq() ;
UART_Start() ;
ADC_Start() ;
}
void splash(void)
{
snprintf(str, STR_LEN, "PSoC 6 ADC Test (%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
void measure(void)
{
int16_t adc_count ;
int16_t mV ;
ADC_StartConvert() ;
ADC_IsEndConversion(CY_SAR_WAIT_FOR_RESULT) ;
adc_count = ADC_GetResult16(0) ;
mV = ADC_CountsTo_mVolts(0, adc_count) ;
snprintf(str, STR_LEN, "%5d mV : %4d\n", mV, adc_count) ;
print(str) ;
return ;
}
int main(void)
{
init_hardware() ;
// __enable_irq(); /* Enable global interrupts. */
// /* Enable CM4. CY_CORTEX_M4_APPL_ADDR must be updated if CM4 memory layout is changed. */
// Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR); /* this time I use only CM0+ */
splash() ;
for(;;)
{
measure() ;
CyDelay(1000) ;
}
}
====================
(5) Tera Term output
(6) I connected 3.3V, GND, and A0 (P10[0]) from the board to a POT (10K)
At 0.000V (~ -0.000V): program reported -2mV ~ 3mV, adc_count -1 ~ 2
At 1.001V program reported 1014 mV ~ 1022 mV, adc_count 629 ~ 632
At 2.007V program reported 2037 mV ~ 2045 mV, adc_count 1264 ~ 1269
At 3.006V program reported 3055 mV ~ 3060 mV, adc_count 1896 ~ 1899
So IMHO, the voltage reported via ADC_CountsTo_mVolts() seems to be reasonable for my hardware setup.
You may want to take a look at inside this function to confirm how they convert ADC count to mV.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When can I expect a Cypress response to this question? Is there another support avenue where I could get responses more reliably?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you tried to use ADC_CountsTo_mVolts() function?
I tried the following using CY8CKIT-062-WIFI-BT (CY8C6247BZI-D54ES on board)
(1) Schematic
(2) ADC Config
Note: Although I tried to duplicate your config, I noticed that the "Scan duration" is quite different from yours.
(3) Pin assign
(4) main.c
====================
#include "project.h"
#include "stdio.h"
#define STR_LEN 128
char str[STR_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
void init_hardware(void)
{
__enable_irq() ;
UART_Start() ;
ADC_Start() ;
}
void splash(void)
{
snprintf(str, STR_LEN, "PSoC 6 ADC Test (%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
void measure(void)
{
int16_t adc_count ;
int16_t mV ;
ADC_StartConvert() ;
ADC_IsEndConversion(CY_SAR_WAIT_FOR_RESULT) ;
adc_count = ADC_GetResult16(0) ;
mV = ADC_CountsTo_mVolts(0, adc_count) ;
snprintf(str, STR_LEN, "%5d mV : %4d\n", mV, adc_count) ;
print(str) ;
return ;
}
int main(void)
{
init_hardware() ;
// __enable_irq(); /* Enable global interrupts. */
// /* Enable CM4. CY_CORTEX_M4_APPL_ADDR must be updated if CM4 memory layout is changed. */
// Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR); /* this time I use only CM0+ */
splash() ;
for(;;)
{
measure() ;
CyDelay(1000) ;
}
}
====================
(5) Tera Term output
(6) I connected 3.3V, GND, and A0 (P10[0]) from the board to a POT (10K)
At 0.000V (~ -0.000V): program reported -2mV ~ 3mV, adc_count -1 ~ 2
At 1.001V program reported 1014 mV ~ 1022 mV, adc_count 629 ~ 632
At 2.007V program reported 2037 mV ~ 2045 mV, adc_count 1264 ~ 1269
At 3.006V program reported 3055 mV ~ 3060 mV, adc_count 1896 ~ 1899
So IMHO, the voltage reported via ADC_CountsTo_mVolts() seems to be reasonable for my hardware setup.
You may want to take a look at inside this function to confirm how they convert ADC count to mV.
moto