- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hi,
I doing a very simple ADC read - but I am getting random values. The codes is below. The ADC is configured as a 10-bit single-ended.
#include "project.h"
uint16 output;
int main(void)
{
ADC_DelSig_1_Start();
ADC_DelSig_1_StartConvert();
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
output = ADC_DelSig_1_Read16();
}
}
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
I have tried that - without any results.. It did actually work once, but not any more. I have attached my code file.
- Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should wait for a conversion ready using ADC_DelSig_1_IsEndConversion(). See parameters in datasheet
Happy coding
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
Instead of
{ | |
if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) | |
{ |
use
ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT);
and define the variable output as int16, not as uint,
Furthermore I suggest you to call at first
CyGlobalIntEnable; | // Iallow any interrupt |
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You seem to set the sample mode to "single sample"
Then you need to start conversion each time.
So how about changing the main.c like ...
==========================
#include <project.h>
uint16 output = 0 ;
int main()
{
CyGlobalIntEnable; // Bob-san's suggestion, and I agree with it
/* Start the components */
ADC_DelSig_1_Start();
/* Display the value of ADC output on LCD */
/* Start the ADC conversion */
ADC_DelSig_1_StartConvert();
for (;;) {
if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) {
output = ADC_DelSig_1_GetResult16() ;
/* Start next ADC conversion */
ADC_DelSig_1_StartConvert();
}
}
}
==========================
moto