This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:software:homelab:library:timer [2010/03/25 18:21] – mikk.leini | en:software:homelab:library:timer [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Timers ====== | ====== Timers ====== | ||
- | This library covers large part of the functionality of ATmega128 timers. There are data types and functions which make usage of timers easier. Unfortunately, | + | This library covers |
===== Data types ===== | ===== Data types ===== | ||
Line 56: | Line 56: | ||
* **//void timer0_init_normal(timer0_prescale prescale)// | * **//void timer0_init_normal(timer0_prescale prescale)// | ||
- | Initializes timer 0 in normal mode. In this mode timer counts from 0 to 255 (including). | + | Initializes timer 0 in normal mode. In this mode the timer counts from 0 to 255 (including). |
* // | * // | ||
* **//void timer2_init_normal(timer2_prescale prescale)// | * **//void timer2_init_normal(timer2_prescale prescale)// | ||
- | Initializes timer 2 in normal mode. In this mode timer counts from 0 to 255 (including). | + | Initializes timer 2 in normal mode. In this mode timer counts from 0 to 255 (including). |
* // | * // | ||
Line 79: | Line 79: | ||
* **//void timer0_overflow_interrupt_enable(bool enable)//** | * **//void timer0_overflow_interrupt_enable(bool enable)//** | ||
* **//void timer2_overflow_interrupt_enable(bool enable)//** \\ | * **//void timer2_overflow_interrupt_enable(bool enable)//** \\ | ||
- | Enables or disables timer 0/2 overflow interrupt. | + | Enables or disables timer 0/2 overflow interrupt. |
* //enable// - //true// to enable interrupt, //false// to disable. | * //enable// - //true// to enable interrupt, //false// to disable. | ||
Line 93: | Line 93: | ||
* **//void timer1_init_normal(timer1_prescale prescale)// | * **//void timer1_init_normal(timer1_prescale prescale)// | ||
* **//void timer3_init_normal(timer3_prescale prescale)// | * **//void timer3_init_normal(timer3_prescale prescale)// | ||
- | Initializes timer 1/3 in normal mode. In this mode timer counts from 0 to 65535 (including). | + | Initializes timer 1/3 in normal mode. In this mode timer counts from 0 to 65535 (including). |
* // | * // | ||
* **//void timer1_init_ctc(timer1_prescale prescale, timer1_ctc_top top)//** | * **//void timer1_init_ctc(timer1_prescale prescale, timer1_ctc_top top)//** | ||
- | * **//void timer3_init_ctc(timer3_prescale prescale, timer3_ctc_top top)//** \\ Taimer | + | * **//void timer3_init_ctc(timer3_prescale prescale, timer3_ctc_top top)//** \\ |
- | * // | + | Initializes timer 1/3 in CTC (//Clear Timer on Compare Match// |
- | * //top// - Taimeri maksimaalse väärtuse registri valik. Valida saab kahe registri vahel, mille mõlema muutmiseks on omaette funktsioonid. Mõlemad registrid võib loenduri tippu jõudes katkestust tekitama seadistada. | + | * // |
+ | * //top// - Timer top value selection. Actual value must be specified with register selected as a top value holder. | ||
* **//void timer1_init_fast_pwm(timer1_prescale prescale, timer1_fast_pwm_top top, timer1_fast_pwm_output_mode output_a, timer1_fast_pwm_output_mode output_b, timer1_fast_pwm_output_mode output_c)// | * **//void timer1_init_fast_pwm(timer1_prescale prescale, timer1_fast_pwm_top top, timer1_fast_pwm_output_mode output_a, timer1_fast_pwm_output_mode output_b, timer1_fast_pwm_output_mode output_c)// | ||
- | * **//void timer3_init_fast_pwm(timer3_prescale prescale, timer3_fast_pwm_top top, timer3_fast_pwm_output_mode output_a, timer3_fast_pwm_output_mode output_b, timer3_fast_pwm_output_mode output_c)// | + | * **//void timer3_init_fast_pwm(timer3_prescale prescale, timer3_fast_pwm_top top, timer3_fast_pwm_output_mode output_a, timer3_fast_pwm_output_mode output_b, timer3_fast_pwm_output_mode output_c)// |
- | * // | + | Initializises timer 1/3 in fast PWM mode. In this mode timer counts to a specified value, which also determines the period of the PWM signal. Timer 1/3 has three 3 output compare units (A, B and C) to generate PWM signals. Overflow and compare match interrupts can be used. Parameters: |
- | * //top// - Taimeri maksimaalse väärtuse valik. Valida saab konstantide ja kahe registri vahel. Mõlemad registrid võib loenduri tippu jõudes katkestust tekitama seadistada. | + | * // |
- | * // | + | * //top// - Timer top value selection. Actual value must be specified with register selected as a top value holder. |
- | * // | + | * // |
- | * // | + | * // |
+ | * // | ||
* **//void timer1_stop()// | * **//void timer1_stop()// | ||
- | * **//void timer3_stop()// | + | * **//void timer3_stop()// |
+ | Stops timer 1/3. | ||
* **// | * **// | ||
- | * **// | + | * **// |
- | * Tagastab | + | Returns timer 1/3 current value. Parameters: |
+ | * Returns | ||
* **//void timer1_set_value(unsigned char value)//** | * **//void timer1_set_value(unsigned char value)//** | ||
- | * **//void timer3_set_value(unsigned char value)//** \\ Taimeri 1/3 loenduri uue väärtuse määramine. Parameters: | + | * **//void timer3_set_value(unsigned char value)//** \\ |
- | * //value// - Uus 16-bitine loenduri väärtus. | + | Sets timer 0/2 value. Parameters: |
+ | * //value// - New 16-bit timer value. | ||
* **// | * **// | ||
Line 125: | Line 130: | ||
* **// | * **// | ||
* **// | * **// | ||
- | * **// | + | * **// |
- | * Tagastab | + | |
+ | * Returns | ||
* **//void timer1_set_compare_match_unitA_value(unsigned short value)//** | * **//void timer1_set_compare_match_unitA_value(unsigned short value)//** | ||
Line 133: | Line 139: | ||
* **//void timer3_set_compare_match_unitA_value(unsigned short value)//** | * **//void timer3_set_compare_match_unitA_value(unsigned short value)//** | ||
* **//void timer3_set_compare_match_unitB_value(unsigned short value)//** | * **//void timer3_set_compare_match_unitB_value(unsigned short value)//** | ||
- | * **//void timer3_set_compare_match_unitC_value(unsigned short value)//** \\ Taimeri | + | * **//void timer3_set_compare_match_unitC_value(unsigned short value)//** \\ |
- | * //value// - Uus 16-bitine võrdlusväärtus. | + | Sets timer 1/3 output compare unit A/B/C compare match register value. Parameters: |
+ | * //value// - New 16-bit compare match register value. | ||
* **// | * **// | ||
- | * **// | + | * **// |
- | * Tagastab | + | Returns timer 1/3 input capture register value. Parameters: |
+ | * Returns | ||
* **//void timer1_set_input_capture_value(unsigned short value)//** | * **//void timer1_set_input_capture_value(unsigned short value)//** | ||
- | * **//void timer3_set_input_capture_value(unsigned short value)//** \\ Taimer | + | * **//void timer3_set_input_capture_value(unsigned short value)//** \\ |
- | * //value// - Uus 16-bitine sündmuste loenduri väärtus. | + | Sets timer 1/3 input capture register value. Parameters: |
+ | * //value// - New 16-bit input capture register value. | ||
* **//void timer1_overflow_interrupt_enable(bool enable)//** | * **//void timer1_overflow_interrupt_enable(bool enable)//** | ||
- | * **//void timer3_overflow_interrupt_enable(bool enable)//** \\ Taimer | + | * **//void timer3_overflow_interrupt_enable(bool enable)//** \\ |
+ | Enables or disables timer 1/3 overflow interrupt. The name of the interrupt vector is "TIMERn_OVF_vect" where " | ||
* //enable// - //true// to enable interrupt, //false// to disable. | * //enable// - //true// to enable interrupt, //false// to disable. | ||
Line 153: | Line 163: | ||
* **//void timer3_compare_match_unitA_interrupt_enable(bool enable)//** | * **//void timer3_compare_match_unitA_interrupt_enable(bool enable)//** | ||
* **//void timer3_compare_match_unitB_interrupt_enable(bool enable)//** | * **//void timer3_compare_match_unitB_interrupt_enable(bool enable)//** | ||
- | * **//void timer3_compare_match_unitC_interrupt_enable(bool enable)//** \\ Taimer | + | * **//void timer3_compare_match_unitC_interrupt_enable(bool enable)//** \\ |
+ | | ||
* //enable// - //true// to enable interrupt, //false// to disable. | * //enable// - //true// to enable interrupt, //false// to disable. | ||
* **//void timer1_input_capture_interrupt_enable(bool enable)//** | * **//void timer1_input_capture_interrupt_enable(bool enable)//** | ||
* **//void timer3_input_capture_interrupt_enable(bool enable)//** \\ | * **//void timer3_input_capture_interrupt_enable(bool enable)//** \\ | ||
- | Enables or disables timer 1/3 input capture interrupt. | + | Enables or disables timer 1/3 input capture interrupt. |
* //enable// - //true// to enable interrupt, //false// to disable. | * //enable// - //true// to enable interrupt, //false// to disable. | ||