Universal Software Timer Main Page: Unterschied zwischen den Versionen
Aus ProjectWiki
Mat (Diskussion | Beiträge) (Created page with "== Download == * [http://www.braunecker.at/downloads/tickers_1_0.zip tickers.bas Version 1.0]") |
Mat (Diskussion | Beiträge) |
||
| Zeile 1: | Zeile 1: | ||
| + | This is an easy-to-use universal software timer library, for use with any hardware timer, featuring automatic determination of needed timer parameters on precompile, up to 256 independant software timers, each can be enabled/disabled and an interrupt queue if more than one sw interrupt occured at once. | ||
| + | |||
| + | Free for personal use, credits and a short mail with your project info and/or comments, improvements etc. to this library would be nice. | ||
| + | |||
| + | |||
| + | ==How to use this== | ||
| + | the values are just for example | ||
| + | |||
| + | Initialisation: | ||
| + | <pre>$crystal = 16000000 | ||
| + | '[...] ' your Code | ||
| + | Const False = 0: Const True = 1 ' make it more readable | ||
| + | |||
| + | Const Ticker_hwtimer = 0 ' Choose which hardware timer to use | ||
| + | Const Ticker_frequency = 10000 ' set the timer resolution | ||
| + | Const Tickers = 2 ' # of software timers to use | ||
| + | $include "tickers.bas" | ||
| + | Ticker_time(1) = 25 ' Interrupt Ticks to trigger SW-Timer 1 | ||
| + | Ticker_time(2) = 500 ' SW-Timer 2 and so on... | ||
| + | Ticker_enabled(1) = True ' Enable/Disable SW-Timer | ||
| + | Ticker_enabled(2) = False | ||
| + | '[...] | ||
| + | Enable Interrupts</pre> | ||
| + | |||
| + | Main Loop: | ||
| + | <pre>>Do | ||
| + | '[...] | ||
| + | Select Case Ticker_get_interrupt() ' make sure that this function is called at least once per | ||
| + | ' hw timer overflow, so don't make the µC hanging around | ||
| + | Case 1: ' Ticker 1 triggered an interrupt | ||
| + | '[...] | ||
| + | Case 2: ' Ticker 2 interrupt | ||
| + | '[...] | ||
| + | End Select | ||
| + | |||
| + | '[...] | ||
| + | Loop</pre> | ||
| + | |||
== Download == | == Download == | ||
* [http://www.braunecker.at/downloads/tickers_1_0.zip tickers.bas Version 1.0] | * [http://www.braunecker.at/downloads/tickers_1_0.zip tickers.bas Version 1.0] | ||
Aktuelle Version vom 4. Juni 2011, 21:15 Uhr
This is an easy-to-use universal software timer library, for use with any hardware timer, featuring automatic determination of needed timer parameters on precompile, up to 256 independant software timers, each can be enabled/disabled and an interrupt queue if more than one sw interrupt occured at once.
Free for personal use, credits and a short mail with your project info and/or comments, improvements etc. to this library would be nice.
How to use this
the values are just for example
Initialisation:
$crystal = 16000000 '[...] ' your Code Const False = 0: Const True = 1 ' make it more readable Const Ticker_hwtimer = 0 ' Choose which hardware timer to use Const Ticker_frequency = 10000 ' set the timer resolution Const Tickers = 2 ' # of software timers to use $include "tickers.bas" Ticker_time(1) = 25 ' Interrupt Ticks to trigger SW-Timer 1 Ticker_time(2) = 500 ' SW-Timer 2 and so on... Ticker_enabled(1) = True ' Enable/Disable SW-Timer Ticker_enabled(2) = False '[...] Enable Interrupts
Main Loop:
>Do
'[...]
Select Case Ticker_get_interrupt() ' make sure that this function is called at least once per
' hw timer overflow, so don't make the µC hanging around
Case 1: ' Ticker 1 triggered an interrupt
'[...]
Case 2: ' Ticker 2 interrupt
'[...]
End Select
'[...]
Loop