Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

sikic_2459276
New Contributor

iam new to psoc .can any help me how to measure frequency input from function generator and the output is of enabling port by logic 

0 Likes
16 Replies
SerhiyM_66
Employee

You can use the Timer component in PSoC Creator and take the Timer example project (available in PSoC Creator) which shows how to use the Capture and Terminal Count interrupts. You can modify for your purposes for measuring the frequency (for small frequencies - reading the period, for large  frequencies  - counting the number of pulses).

0 Likes
sikic_2459276
New Contributor

iam not getting the readcapture value can you please send me the logic how to get the freq some code pls 

0 Likes
Anonymous
Not applicable

Here is an example using the "Counter" method to count frequency from 0 to 65.535 kHz.

0 Likes
sikic_2459276
New Contributor

thanks for idea but the problem is iam not getting the read counter value and the debugging is stopped while function generator input  is given to the port .iam using Psoc 4200m series kit .help me with the frequency measurement while function generator input is given to port and it has to perform some logic based on freq value . top design pls 

0 Likes
Bob_Marlowe
Expert II

Can you please post your complete project so that we all can have a look at all of your settings.  To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

Be a little bit more precise what works and what does not work.

   

 

   

Bob

0 Likes
sikic_2459276
New Contributor

input is given from function generator .i want a design such that it will give the frequency measurement whenever required not all the time 

0 Likes
Bob_Marlowe
Expert II

Do not use Pin P0_7: It is connected to the user switch. Pressing the switch will shorten your function generator output to ground. See schematics.

   

CC_ISR_flag must be declared as "volatile" See here.

   

The frequent reload of the counter and _StartEx of the interrupt handler will interfere with the normal frequency measure. Both are needed at project initialization only. Your counter is already configured for resetting at the right times.

   

 

   

Bob

0 Likes
sikic_2459276
New Contributor

the problem iam facing is that the function freq() is not returning any value .

   

as per your suggestion i am changing the port to 0.0. and the CC_ISR_Flag defined as Volatile .

   

can you please get me the code such that it has to measure the freq whenever it is called . iam new to psoc please help me with it 

0 Likes
Bob_Marlowe
Expert II

I changed the LED (which is blue, not red) to P1_6 (didn't you find the schematic on your PC?)

   

Reload and capture might not work together for a counter: what gets executed first? I would suggest to reload the counter in the interrupt handler.

   

 

   

Bob

0 Likes
sikic_2459276
New Contributor

the program is in the infinite for loop and not executing any statements .may be my approach is wrong can any give me the help to perform the frequency measurement task .new design with minimal code pls 

0 Likes
Bob_Marlowe
Expert II

Are you telling that the frequ() function is not called??? check (using a breakpoint) if the capture interrupt fires. When not, scope your input signal.

   

 

   

Bob

0 Likes
sikic_2459276
New Contributor

by the following code i can get the time stamp and freq  but i dont want the freq all the time i want to write it in a function and whenever called the function it has to return the freq .

   

the code which has edited and the other with timer and counter has not worked at all .

   

i donno why readcapture() or Readcounter () is not updating while debugging the value is 0 

0 Likes
Bob_Marlowe
Expert II

It is not possible to help you without the complete project. As I see you reverted some of the corrections I made, so your file contains some errors.

   

 

   

Bob

0 Likes
sikic_2459276
New Contributor

that is the working code but this will continuously display the time stamp in through uart .

   

but my requirement is whenever required only it should give the freq value

   

ex.only at  the time of button press it has give the freq value and some logic like below some set freq led has to glow

0 Likes
Bob_Marlowe
Expert II

Working project attached.

   

 

   

Bob

0 Likes
Bob_Marlowe
Expert II

what more you have to do is query the UserSwitch_Read() == 0 and then call for display the value

   

Glowing of LED is best done using the PriSM component.

   

 

   

Bob

0 Likes