You are here

Better way to measure pulse? | Cypress Semiconductor

Better way to measure pulse?

Summary: 3 Replies, Latest post by danaaknight on 29 Jul 2014 11:44 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
tdvdesign's picture
187 posts



I am working on a project that needs to decode 4 pulse width inputs and modify them to output a different pulse if a high temperature situation occurs (to fade down the output of the original device).  My project is attached below.  It is based on a project that Dana Knight proposed for a PSOC 5. 

I am using the Edge detectors because I cannot have multiple pins in the same bank that have an ISR output, only one per bank.

I am a bit frustrated, as it seems that a few other microcontroller platforms that I have used have had a simple pulse measurement function and pulse output function built in, and all that was required was a pulsein() and pulseout() command.  Trying to modify the software to measure one pulse has already resulted in something very bloated, and that is not working correctly.  I end up with duty cycles of well over 100%.

One other frustration that I have had is that when I change a system variable, like the frequency of the edge detector clock in this case, my custom code in all of the ISRs is completely deleted, and they are rebuilt as they were originally.  Does anyone know why this happens, and what I can do about it?

Thank you all so much, I am obviously not a programming guru, but this forum is helping me to learn a lot.


user_1377889's picture
9294 posts

Just to answer your last request first:

Do NOT put code into one of the generated files. The system allows for that, but (as your own experiences show) this is not the best habit.

In the "System reference Guide" (Creator -> Help -> System Reference) search for "CY_ISR" and you get knowledge how to implement interrupt handlers within your own code in main.c.



tdvdesign's picture
187 posts

Thanks for the tip. It does intriguingly say "Place your Interrupt code here". I will try to make these changes and report back.

user_14586677's picture
7646 posts

In the system generated ISRs there is a placeholder for declaring code

and another one at top of file for declaring externals, variables, etcc.

That code does NOT get overwritten. Unless you delete component and

reinstantiate it from one build to another.


Note you cannot add code outside the placeholders, it will get overwritten.


The CY_ISR is also nice, eg. C isr of your own making. Some prefer this

to the placeholder constraints.


Regards, Dana.

Log in to post new comments.