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..
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.
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.
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
If you use ISR set it up as C isr as follows -
CY_ISR_PROTO(MyIntFunc); // Prototype declaration
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.
uint8 volatile Intcnt;
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.