- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For some reason, I cannot get the ADC to work on this project (attached). I am using miniprog3 for debugging and have a varying DC signal on the input pin to an op-amp. The op-amp output is internally wired to one input of the SAR ADC. Program compiles ok, except I get a warning that one of my variables "result" is declared but not used. I don't understand that- code is below. Anyway when debugging, with 0 V input or 5 V input the "result" is 0x05DB (or something like that) and changes a little from read to read, but does not reflect input voltage at all.
What stupid thing am I doing wrong?
#include <project.h>
int main()
{
int16 result;
ADC1_Start();
for(;;)
{
ADC1_StartConvert();
ADC1_IsEndConversion(ADC1_WAIT_FOR_RESULT);
result = ADC1_GetResult16(0);
ADC1_StopConvert();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to be of some help.
I left everything else as is.
I did not make my hints and suggestions as a guess what might go wrong 😉
When you do not want to bypass Vref, select ADC's Vref without bypassing.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good idea would be to call
OpAmp_1_Start
constrain the input voltage to 0 ... 1.023V
move StartConvert() out of the loop
delete StopConvert()
You need to place a bypass cap 0.1 to 1µF between P1_7
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob,
The problem is OpAmp_1_Start. I did not realize it had to be started. That makes sense if trying to conserve power.
I left everything else as is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to be of some help.
I left everything else as is.
I did not make my hints and suggestions as a guess what might go wrong 😉
When you do not want to bypass Vref, select ADC's Vref without bypassing.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, I can't imagine why anyone would NOT bypass Vref. If I select Vref with bypass, I assume that connects Vref to the bypass cap that is already present at p1_7 on the kit. But if I select Vref without bypass does it simply disconnect p1_7 from Vref? If so, how could I connect my own bypass cap, unless I simply replace what is on the kit?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"But if I select Vref without bypass does it simply disconnect p1_7 from Vref? "
Simply: Yes.
You did not tell which board you used, so I assumed one without a cap on P1_7.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You get the warning because 'result' is only written, but never read. This means the compiler is free to optimize it away (maning you won't see the result in the debugger then).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hli, great to know that about how the compiler optimizes my variable away. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am doing project on PSoC 4 CY8CKIT 049 42xx.
I have attached the .zip file which contains adc and uart code. I have written it to measure temperature and send it to virtual terminal using uart, but I have failed to do that. Iam not getting where I am going wrong. please see that and reply me with solution or zip file or with code. you can send another code doing the same for above kit with .c file and topdesign.cysch.
This will help for my project. I am eagerly waiting for your reply.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Increase heap to 0x0200 in .cydwr view, System tab.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i got it.i incresed it to 200.
but i am not getting why UART_UartPutcharor putstring need to be chcked whether their is any data in string or any data is received
eg.
if i have to send a string then i need to write it like this
ch = UART_UartGetChar();
if(ch)
{
UART_UartPutString("cyp");
}
if i directly send the string like
UART_UartPutString("cyp");
it gives the error that
com port not detected or not found or com port error.
but if i send as per first eg. that error goes off; i.e, firstly i need to receive and check wheather the char is received or not and if true my string will be send. without this i am getting error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is quite unusual, can you please upload your current project to check it?
And please explain what terminal emulation program you use and which operating system.
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
spend your variable str a bit more space, use str[16]
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found a problem. the problem was actually with a HyperTerminal. When I used TeraTerm there is no such an error. just need to give some delay after print string.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to make GLCD component for PSoC 4
If you have that component and its API for CY8CKIT-049-42xx please send me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which counter should i use in PSoC 4 CY8CKIT049 42xx to only count pulses
1.basic counter
2.counter
3.timer counter tcpwm
4.timer counter pwm mode
i have to just count only pulses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Counter or TCPWM configured as counter will be the best. In the datasheets of the components you''l find usually in the beginning a "When to use a ...". Good to compare the features.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I ma using CY8CKIT-049-42xx kit for project.P
I have used the counter component to count the pulses & switch to give pulses to counter which is at P0.7. then i have send that result to uart to see count but i am not getting required result.
Previously i was getting but currently not getting.
i haven't changed anything from that project still this is happening.
It sometimes gives correct output and sometimes garbage value.
i am not getting wheather this is software or hardware problem.
i have attached zip file of project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With a definition of
char cnt[4];
and
sprintf(cnt,"%4d",a);
cnt is dimensioned too small. There is a trailling 0x00 to terminate the string. Declare cnt generously, scrren width is 80, so use 81 to be safe.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are two principles measuring a frequency:
- You need a timer which is used as a time-base. A counter is used co count the number of pulses during the time. Start, reset counter etc is done in software. Best solution for high frequencies.
- You need a stable clock which you count during one period of the frequency to measure. Counter can use capturing to ease programming. Best solution for lower frequencies.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please, when you have a new question open a new discussion thread. Nobody will supect a question about frequency measurement in a SAR ADC topic. Having a separate thread will increase your chances of getting a good answer (since people knowledgeable can see it), and will help other users to find it later on.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As for the GLCD comment, I made a component for PSoC 4 a while back. I use the ST7565R Controller. The code is still there I think for other controllers.
http://www.cypress.com/forum/psoc-community-components/component-st7565r-based-lcds
There is the link. I hope it helps you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello, is it possible to have the solution. Thank you.