- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I am facing a problem while implementing ADC in PSoC. The use of "uint32 ADC_IsEndConversion(uint32 retMode)" gives an error while inserting retMode i.e., ADC_RETRUN_STATUS or ADC_WAIT_FOR_RESULT.
The only way forward is to insert "0" as retMode but still, the ADC results are wrong. I am using the following code:
#include "project.h"
#include "math.h"
#include "stdio.h"
float Is;
int main(void)
{
Is=0;
__enable_irq(); /* Enable global interrupts. */
ADC_Start();
for(;;)
{
ADC_StartConvert();
if(ADC_IsEndConversion(0))
{
Is=ADC_CountsTo_Volts(0, ADC_GetResult32(0));
if (Is<1) //A simple check for the ADC values
Cy_GPIO_Inv(test_PORT,test_NUM);
}
ADC_StopConvert();
}
}
Solved! Go to Solution.
- 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
ADC_IsEndConversion(0) is wrong, valid values start at 1
You do not wait for a conversion done, you stop before it is done.
Use the given constants ADC_WAIT_FOR_RESULT or ADC_RETURN_STATUS. Maybe a typo in the name? Check in generated file ADC.h
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Bob, for your continuous help over the past few years.
I have updated my PSoC creator to 4.2 Beta 2 and came to know that the PDL of the ADC has been changed. So, or CY_SAR_RETURN_STATUS or CY_SAR_WAIT_FOR_RESULT are required as retMode. But the problem still persists with the ADC results i.e., I still get the toggled signal, though I have grounded both input terminals to ADC. Also, how can I watch my variable 'Is' in PSoC Creator?
My updated code is given below and I have also attached my project:
#include "project.h"
#include "math.h"
#include "stdio.h"
float Is;
int main(void)
{
Is=0;
__enable_irq(); /* Enable global interrupts. */
ADC_Start();
for(;;)
{
ADC_StartConvert();
ADC_IsEndConversion(CY_SAR_WAIT_FOR_RESULT);
Is=ADC_CountsTo_Volts(0, ADC_GetResult32(0));
if (Is>2) //A check for the ADC values
Cy_GPIO_Inv(test_PORT,test_NUM);
ADC_StopConvert();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not want to overload my pc with uneeded programs, Can you lplease use the Creator to make a project archive.
To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- 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
And I even can't find any code example of illustrating Scanning ADC in PSoC 6.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are two examles listed in the datasheet, whith and without using an interrupt.
Having a look into the board schematics reveils that there is no connection to a port, but to an internal capacitor on port P7_7
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, somehow it is working now as I have changed the input pin.