Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
Dynamically Changing the Period Value of Timers, Counters, and PWMs in PSoC® 3/4/5LP – KBA88172
Question: How do you change the period value of Timer, Counter, and PWM Components on the fly in PSoC® 3/4/5LP?
The period value of fixed-function or universal digital block (UDB)-based Timer, Counter, and PWM Components can be changed on the fly using the WritePeriod() APIs given here. The new period value will be loaded only when the counter resets to zero.
You can also force the period value to take effect immediately by manually resetting the counter using the WriteCounter() API call given here.
The change in the period of Timer/Counter/PWM made using the WritePeriod API is valid only if they are called after the Start API. Calling the Start API resets the period to the setting made in the Component Configuration window.
When the new period value written into the period register is lesser than the previous value, it is recommended to call the WriteCounter(0) API immediately after that.
To cause the counter count for N cycles, the period variable needs to be written as N-1.