cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1

Anonymous
Not applicable

Hi, I want to drive led with the help of timer output  but i am not able to do it. i am confused with the timer block. Please help me with an example project how to get the return value from a timer.. how to interface an lcd and led with the timer..   

0 Likes
5 Replies
Bob_Marlowe
Expert II

When you right click on the timer-component you can select "Find Example Project" which will answer your question.

   

As you said "Controlling an LED with a timer" What for?

   

What/how do you want to control an LCD with a timer??

   

Did you already read in the timer's datasheet the chapter "When to use a timer component"?

   

There are about 20 APIs listed for the timer component. Since you do not capture any values, leave off all with "Capture" in their name.

   

You do not trigger anything, so forget trigger APIs

   

You do not use interrupts, you do not control the timer, you do neither read nor write the counter or period, so the only remaining APIs are Start(), Stop() and ReadStatusRegister(). To read what these functions do might help you coding what you want to perform.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 the project goes like this.. if switch pressed then timer start and after the up timer counter is over the status of the led get toggled, then again the timer start its counter and then again the pattern of the led lighting changes.. 

   

with the help of firmware delay we can do it.. but was trying with the timer component..  so i was confused whether this will work or not, i was not able to get the return value from the timer output.

0 Likes
ETRO_SSN583
Esteemed Contributor

If you are simply trying to create a delay to an event then set the timer

   

up with a clock, one shot mode, add an ISR to Tc or Compare out, write the

   

period value to the timer, compare value if using that as well, and trigger it

   

with HW or start it in SW when you want the timer to start.

   

 

   

   

 

   

Keep in mind the timer period is (period value) / clkin, this is value you write to its period register using

   

timer API.

   

 

   

If you use ISR set it up as C isr as follows -

   

 

   

    

   

         

   

CY_ISR_PROTO(MyIntFunc);      // Prototype declaration

   

then

   

CY_ISR(MyIntFunc)                         // Interrupt function definition

   

{

   

// Place code here

   

}

   

 

   

In  initialization part of the program

   

 isr_StartEX(MyIntFunc);               // Start Interrupt with my handler

   

 

   

CY_ISR-macro have a look into the "System Reference Guide" under Help -> Documentation..

   

 

   

Set isr properties to rising edge.

   

 

   

Make sure global interrupts are enabled.

   

 

   

    CyGlobalIntEnable;
 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 I have done something what you have said... i am uploading the project please have a look into it and suggest me what can be done or rectified..

0 Likes
ETRO_SSN583
Esteemed Contributor

uint8 Intcnt;

   

should be

   

uint8 volatile Intcnt;

   

 

   

    

   

         

   

http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword    Volatile

   

 

   

 

   

   

 

   

I set timer up to generate 100 mS delay from trigger, then it fires the ISR, where

   

you in turn toggle the LED, and issue a timer start again as it is in one shot mode.

   

 

   

The clk input to timer and timer period value determine delay.

   

 

   

   

 

   

Regards, Dana.

0 Likes