It's all in the Timing
Fig 1. The Timer Component in its simplest configuration driving a LED.
It's always handy to know how each mechanism works properly.
This article discusses what can be done with the Timer (V2.5) Component.
Note:The PSoC 4 with the Pioneer Kit supports the UDB version.
I've worked through this component step by step to develop a decent understanding of it.
The first task is to get the timer working in its default and simplest configuration.
This is a continuous periodic timer that is a down counter that is loaded with a starting value.
When its counter reaches zero it outputs this status through its TC pin.
The TC asserted state only lasts for a single clock cycle before it is automatically reset to the negated state.
Adding human detectable feedback
I've configured the above timer for a 500ms period by using the following settings.
It is just the default settings but with the Resolution changed to 24-bit and the Period adjusted to 500ms.
The timer can be used to blink an LED but if the source clock cycle period is too short nothing can be seen.
To overcome this a Toggle FF(Flip-Flop) (with its T pin at logic '1') can be used with the TC output feeding the Toggle FF's clock input.
This means any LED connected to the Toggle FF's Q output will toggle its state at the beginning of a TC pulse.
The LED will therefore remain it its new state until another TC pulse is encountered (which is at the defined period of the Timer).
So with no code other than Timer_1_Start() in the initialisation portion of the main.c, we can make an LED blink at half the selected Timer frequency.
In later posts I'll discuss slightly more complex configurations.


Top Comments