How do I program the timer?

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

   

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!

0 Likes
4 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

isr_StartEx(YourHandler)

   

 

   

Bob

   

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

0 Likes
Anonymous
Not applicable

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: alexmosk@web.de

   

 

   

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!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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: alexmosk@web.de

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.

   

 

   

Bob
 

0 Likes