Dynamically Changing the Period Value of Timers, Counters, and PWMs in PSoC® 3/4/5LP
Employee
Mar 03, 2011
08:34 PM
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Mar 03, 2011
08:34 PM
How to 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.
- Timer_WritePeriod(period);
- PWM_WritePeriod(period);
- Counter_WritePeriod(period);
You can also force the period value to take effect immediately by manually resetting the counter using the WriteCounter() API call given here.
- Timer_WriteCounter(0);
- PWM_WriteCounter(0);
- Counter_WriteCounter(0);
Note:
- 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.
- Tags:
- 32-bit arma cortexa-m0 psoca 4
- 32-bit arma cortexa-m3 psoca 5lp
- Counters
- Period Value of Timers
- psoca 3
- psoca 5
- psoca software
- psoc® 3
- psoc® 4
- psoc® 5lp
- PWMs
Rate this article: