You are here

How do I program the timer? | Cypress Semiconductor

How do I program the timer?

Summary: 4 Replies, Latest post by Bob Marlowe on 28 Oct 2015 11:38 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
alexmosk_1509446's picture
2 posts


I'm new here and have never programmed a PSoC. I need your help.

I want to decode the German longwave time signal. I get every second a pulse, which is either 100 ms or 200 ms long. Now I have to measure the time between the falling edge and the rising edge to find the minute mark and decode the signal.

How I have to program the timer that it start the measure by a falling edge and end the measure by a rising edge? How I can get the result of the measure to define the Bit 1 or 0?

I have a CY8C5888LTI-LP097.

Thank You!


user_78878863's picture
2553 posts

Run the timer as a counter, with a clock of e.g. 1khz. The use the enable input to run the counter only when the pulse is active. last part is an ISR triggered by the rising flank of the pulse. In the ISR you can read the counter value and reset it for the next pulse.

user_1377889's picture
9274 posts

Welcome in the forum, Alex!

One addition to hli's working solution:

Under Creator's Help you'll find a reference to the "System Reference Guide" where some explanation about interrupts are.

Define your interrupt handler with

CY_ISR_PROTO(YourHandler); // Prototype definition

Declare the handler as

CY_ISR(YourHandler)  // Declaration of handler

   // Remove Timer's interrupt cause by reading the status
  // Read value and store in a global var

  //stop timer 
  // Start Timer again


Bind the handler to the isr with




PS: Where in Germany are you located, I am living near Bremen and hli near/in Magdeburg


alexmosk_1509446's picture
2 posts

Danke für die schnellen Antworten.

Ich hoffe, dass ich gegen keine Richtlinien verstoße, wenn ich hier auf deutsch schreibe. Also ich komme aus Cloppenburg, was ca. 70 km südwestlich von Bremen liegt. Ich würde mich freuen, wenn ich evtl. eure E-Mail Adresse bekommen könnte, damit wir eine schnellere Kommunikation haben können, in der ich dann alle meine Fragen loswerden kann. Meine E-Mail Adresse lautet:


Zurück zum Problem:

Bisher habe ich das Modul "Timer" verwendet, um die Messung durchzuführen. Leider nicht erfolgreich. So wie hli verstanden habe, soll ich stattdessen besser das Modul "Counter" verwenden. Welche Einstellungen muss ich denn genau vornehmen? Und wie genau setze ich einen Interrupt, um das Ergebnis auszulesen und den Counter zurückzusetzen?

Bin ein echter Amateur auf diesem Gebiet und deswegen dankbar für jede Antwort!

user_1377889's picture
9274 posts

No, Alex, the forum language is English. Easiest would be to have a translator converting your text for all of us.

Alex wrote (translated)

Thanks for the quick replies.

I hope that I violate no rules when I write here in German. So I'm from Cloppenburg, which is located about 70 km southwest of Bremen. I would be glad if I could get your e-mail address might, so that we can have faster communication in which I can then get rid of all my questions. My email address is:

Back to the problem:

So far I have the module "Timer" is used to perform the measurement. Unfortunately unsuccessful. Just as HLI have understood, I should better use the module "Counter" instead. What settings do I have to do exactly? And how exactly do I use an interrupt to read out the result and return the counter?

Am a true amateur in this field and so grateful for every answer!

Alex, I usually do not give away my email address, would be too much traffic, forum is quite enough.

I suppose you have got a CY8CKIT.059 Prototype Kit and you have successfully installed Creator 3.3 and already tried one of the examples to compile and run.

There is no way, but you will have to read and understand the datasheets.

When you right click on a component you can select from the pop-up menu "Open Datasheet". More information you will get from example projects using timers and / or counters.




Log in to post new comments.