Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 4

Jweaver
Level 3
10 replies posted 10 questions asked 5 replies posted
Level 3

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();
             
    }
}

0 Likes
1 Solution
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

View solution in original post

0 Likes
23 Replies
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
Jweaver
Level 3
10 replies posted 10 questions asked 5 replies posted
Level 3

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.

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
Jweaver
Level 3
10 replies posted 10 questions asked 5 replies posted
Level 3

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?  

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

"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

0 Likes
HeLi_263931
Level 8
100 likes received 50 likes received 25 likes received
Level 8

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).

0 Likes
Jweaver
Level 3
10 replies posted 10 questions asked 5 replies posted
Level 3

hli,  great to know that about how the compiler optimizes my variable away.   Thanks

0 Likes
Anonymous
Not applicable

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.
 

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

Increase heap to 0x0200 in .cydwr view, System tab.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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.

   
    1089   
0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
Anonymous
Not applicable

I am using HyperTerminal program to test UART on Windows 7 professional.

   

and the zip file contains the error statements in main.c

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

spend your variable str a bit more space, use str[16]

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

How to make GLCD component for PSoC  4

   

If you have that component and its API for CY8CKIT-049-42xx please send me.

0 Likes
Anonymous
Not applicable

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

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
Anonymous
Not applicable

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.

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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

0 Likes
HeLi_263931
Level 8
100 likes received 50 likes received 25 likes received
Level 8

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!

0 Likes
DaBr_1233126
Level 4
10 likes given 5 likes given First like received
Level 4

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!

0 Likes
LeBo_3704981
Level 1
First reply posted Welcome!
Level 1

hello, is it possible to have the solution. Thank you.

0 Likes